clk: gpio: fix memory leak
PATCH 1/1 clk: gpio: fix memory leak
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 <[email protected]>
--- drivers/clk/clk-gpio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/clk-gpio.c +3 -1
@@ -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);
Signature · 1 line
1.9.1
Michael Turquette
AppliedQuoting Sudip Mukherjee (2015-12-22 22:33:59)
Quoted 5 lines
If we fail to allocate
parent_namethen we are returning but we missed freeing data which has already been allocated.
=Signed-off-by Sudip Mukherjee <[email protected]>
Applied.
Thanks,
Mike
drivers/clk/clk-gpio.c static void __init of_gpio_clk_setup(struct device_n=
Quoted 10 lines
--- drivers/clk/clk-gpio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)=
drivers/clk/clk-gpio.c +0
-0@@ -294,8 +294,10 @@ static void __init of_gpio_clk_setup(struct device_n=
ode *node,
Quoted 17 lines
drivers/clk/clk-gpio.c +3
-1num_parents =3D of_clk_get_parent_count(node); = parent_names =3D kcalloc(num_parents, sizeof(char *), GFP_KERNEL); -if (!parent_names) +if (!parent_names) { +kfree (data);return ; + } =for (i =3D 0; i < num_parents; i++) parent_names[i] =3D of_clk_get_parent_name(node, i);-- =
1.9.1
=20