clk: gpio: fix memory leak
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Wed, 23 Dec 2015 06:33:59 +0000 (12:03 +0530)
committerMichael Turquette <mturquette@baylibre.com>
Fri, 1 Jan 2016 05:31:58 +0000 (21:31 -0800)
If we fail to allocate parent_name then we are returning but we missed
freeing data which has already been allocated.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
drivers/clk/clk-gpio.c

index 335322dc403f48fcf773028d232e5c772f3cd8b5..c1baa89cbf919f40bc263e86b276696a41ec2723 100644 (file)
@@ -294,8 +294,10 @@ static void __init of_gpio_clk_setup(struct device_node *node,
        num_parents = of_clk_get_parent_count(node);
 
        parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL);
-       if (!parent_names)
+       if (!parent_names) {
+               kfree(data);
                return;
+       }
 
        for (i = 0; i < num_parents; i++)
                parent_names[i] = of_clk_get_parent_name(node, i);