The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] clk: spacemit: fix resource leak in spacemit_ccu_reset_register
@ 2025-07-23 12:40 Hendrik Hamerlinck
  2025-07-23 12:54 ` Yixun Lan
  0 siblings, 1 reply; 3+ messages in thread
From: Hendrik Hamerlinck @ 2025-07-23 12:40 UTC (permalink / raw)
  To: sboyd, dlan
  Cc: skhan, linux-kernel-mentees, linux-clk, linux-riscv, spacemit,
	linux-kernel, Hendrik Hamerlinck

The function spacemit_ccu_reset_register() allocates memory for an
auxiliary device. If auxiliary_device_add() fails, it skips cleanup of
these resources, resulting in leaks.

Fix this by using the appropriate error handling path.

Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
Fixes: 988543522ebd ("clk: spacemit: set up reset auxiliary devices")
---
 drivers/clk/spacemit/ccu-k1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index 65e6de030717..5bb85e32c6cf 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -1059,7 +1059,7 @@ static int spacemit_ccu_reset_register(struct device *dev,
 	ret = auxiliary_device_add(adev);
 	if (ret) {
 		auxiliary_device_uninit(adev);
-		return ret;
+		goto err_free_aux_id;
 	}
 
 	return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev);
-- 
2.43.0


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

* Re: [PATCH] clk: spacemit: fix resource leak in spacemit_ccu_reset_register
  2025-07-23 12:40 [PATCH] clk: spacemit: fix resource leak in spacemit_ccu_reset_register Hendrik Hamerlinck
@ 2025-07-23 12:54 ` Yixun Lan
  2025-07-23 13:10   ` Hendrik Hamerlinck
  0 siblings, 1 reply; 3+ messages in thread
From: Yixun Lan @ 2025-07-23 12:54 UTC (permalink / raw)
  To: Hendrik Hamerlinck
  Cc: sboyd, skhan, linux-kernel-mentees, linux-clk, linux-riscv,
	spacemit, linux-kernel

Hi Hendrik, 

On 14:40 Wed 23 Jul     , Hendrik Hamerlinck wrote:
> The function spacemit_ccu_reset_register() allocates memory for an
> auxiliary device. If auxiliary_device_add() fails, it skips cleanup of
> these resources, resulting in leaks.
> 
> Fix this by using the appropriate error handling path.
> 
> Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
> Fixes: 988543522ebd ("clk: spacemit: set up reset auxiliary devices")
Can you put Fixes tag before SoB? I'd suggest to follow tip tree's docs

https://docs.kernel.org/process/maintainer-tip.html
4.2.6. Ordering of commit tags

otherwise, looks good

Reviewed-by: Yixun Lan <dlan@gentoo.org>

> ---
>  drivers/clk/spacemit/ccu-k1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
> index 65e6de030717..5bb85e32c6cf 100644
> --- a/drivers/clk/spacemit/ccu-k1.c
> +++ b/drivers/clk/spacemit/ccu-k1.c
> @@ -1059,7 +1059,7 @@ static int spacemit_ccu_reset_register(struct device *dev,
>  	ret = auxiliary_device_add(adev);
>  	if (ret) {
>  		auxiliary_device_uninit(adev);
> -		return ret;
> +		goto err_free_aux_id;
>  	}
>  
>  	return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev);
> -- 
> 2.43.0
> 

-- 
Yixun Lan (dlan)

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

* Re: [PATCH] clk: spacemit: fix resource leak in spacemit_ccu_reset_register
  2025-07-23 12:54 ` Yixun Lan
@ 2025-07-23 13:10   ` Hendrik Hamerlinck
  0 siblings, 0 replies; 3+ messages in thread
From: Hendrik Hamerlinck @ 2025-07-23 13:10 UTC (permalink / raw)
  To: Yixun Lan
  Cc: sboyd, skhan, linux-kernel-mentees, linux-clk, linux-riscv,
	spacemit, linux-kernel

Hello Yixun,

Thank you for the review.

On 7/23/25 14:54, Yixun Lan wrote:
>> Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
>> Fixes: 988543522ebd ("clk: spacemit: set up reset auxiliary devices")
> Can you put Fixes tag before SoB? I'd suggest to follow tip tree's docs
>
> https://docs.kernel.org/process/maintainer-tip.html
> 4.2.6. Ordering of commit tags
>
> otherwise, looks good
Thanks for pointing that out. I'll send the corrected version in the v2
and make sure to follow the guidelines in the future.
>
> Reviewed-by: Yixun Lan <dlan@gentoo.org>


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

end of thread, other threads:[~2025-07-23 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 12:40 [PATCH] clk: spacemit: fix resource leak in spacemit_ccu_reset_register Hendrik Hamerlinck
2025-07-23 12:54 ` Yixun Lan
2025-07-23 13:10   ` Hendrik Hamerlinck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox