Linux-OMAP Archive on lore.kernel.org
 help / color / 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	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2020-07-28  1:24 UTC (permalink / raw)
  To: Jing Xiangfeng, mturquette, robh, t-kristo, tony
  Cc: linux-omap, linux-clk, linux-kernel, jingxiangfeng

Quoting Jing Xiangfeng (2020-07-20 05:23:43)
> _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;
> +               }

Why not goto cleanup?

>  
>                 hw->enable_reg.ptr = provider->base + reg_data->offset;
>  
> -- 
> 2.17.1
>

^ 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-28  1:24 ` Stephen Boyd
@ 2020-07-28  3:43   ` Jing Xiangfeng
  0 siblings, 0 replies; 5+ messages in thread
From: Jing Xiangfeng @ 2020-07-28  3:43 UTC (permalink / raw)
  To: Stephen Boyd, mturquette, robh, t-kristo, tony
  Cc: linux-omap, linux-clk, linux-kernel



On 2020/7/28 9:24, Stephen Boyd wrote:
> Quoting Jing Xiangfeng (2020-07-20 05:23:43)
>> _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;
>> +               }
>
> Why not goto cleanup?

Thanks, I will change it as you suggested.

>
>>
>>                  hw->enable_reg.ptr = provider->base + reg_data->offset;
>>
>> --
>> 2.17.1
>>
> .
>

^ 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

* 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, back to index

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

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git