linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()
@ 2020-07-20 12:23 Jing Xiangfeng
  2020-07-28  1:24 ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Jing Xiangfeng @ 2020-07-20 12:23 UTC (permalink / raw)
  To: t-kristo, mturquette, sboyd, tony, robh
  Cc: linux-omap, linux-clk, linux-kernel, jingxiangfeng

_ti_omap4_clkctrl_setup() misses to call kfree() in an error path. Add
the missed function call to fix it.

Fixes: 6c3090520554 ("clk: ti: clkctrl: Fix hidden dependency to node name")
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
---
 drivers/clk/ti/clkctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
index 864c484bde1b..868e50132c21 100644
--- a/drivers/clk/ti/clkctrl.c
+++ b/drivers/clk/ti/clkctrl.c
@@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
 		}
 
 		hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-		if (!hw)
+		if (!hw) {
+			kfree(clkctrl_name);
 			return;
+		}
 
 		hw->enable_reg.ptr = provider->base + reg_data->offset;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* Re: [PATCH] clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()
@ 2020-07-20 14:19 Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2020-07-20 14:19 UTC (permalink / raw)
  To: Jing Xiangfeng, linux-clk, linux-omap
  Cc: linux-kernel, kernel-janitors, Michael Turquette, Rob Herring,
	Stephen Boyd, Tero Kristo, Tony Lindgren

…
> +++ b/drivers/clk/ti/clkctrl.c
> @@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
>  		}
>
>  		hw = kzalloc(sizeof(*hw), GFP_KERNEL);
> -		if (!hw)
> +		if (!hw) {
> +			kfree(clkctrl_name);
>  			return;
> +		}
…

I suggest to use an additional label instead.

 		if (!hw)
-			return;
+			goto free_control_name;


By the way:
How do you think about to replace the label “cleanup” by other jump targets
for better exception handling in this function implementation?

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH] clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()
@ 2020-07-20 14:19 Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2020-07-20 14:19 UTC (permalink / raw)
  To: Jing Xiangfeng, linux-clk, linux-omap
  Cc: linux-kernel, kernel-janitors, Michael Turquette, Rob Herring,
	Stephen Boyd, Tero Kristo, Tony Lindgren

…
> +++ b/drivers/clk/ti/clkctrl.c
> @@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
>  		}
>
>  		hw = kzalloc(sizeof(*hw), GFP_KERNEL);
> -		if (!hw)
> +		if (!hw) {
> +			kfree(clkctrl_name);
>  			return;
> +		}
…

I suggest to use an additional label instead.

 		if (!hw)
-			return;
+			goto free_control_name;


By the way:
How do you think about to replace the label “cleanup” by other jump targets
for better exception handling in this function implementation?

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-28  3:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 12:23 [PATCH] clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup() Jing Xiangfeng
2020-07-28  1:24 ` Stephen Boyd
2020-07-28  3:43   ` Jing Xiangfeng
2020-07-20 14:19 Markus Elfring
2020-07-20 14:19 Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).