public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH v2] clk: spacemit: fix resource leak in spacemit_ccu_reset_register
@ 2025-07-23 13:25 Hendrik Hamerlinck
  2025-07-25  2:36 ` Stephen Boyd
  2025-07-26  9:16 ` Christophe JAILLET
  0 siblings, 2 replies; 6+ messages in thread
From: Hendrik Hamerlinck @ 2025-07-23 13:25 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.

Fixes: 988543522ebd ("clk: spacemit: set up reset auxiliary devices")
Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
---
Changes in v2:
- Properly place the Fixes tip.
---
 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] 6+ messages in thread

end of thread, other threads:[~2025-07-26 18:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 13:25 [PATCH v2] clk: spacemit: fix resource leak in spacemit_ccu_reset_register Hendrik Hamerlinck
2025-07-25  2:36 ` Stephen Boyd
2025-07-26  9:16 ` Christophe JAILLET
2025-07-26 12:10   ` Yixun Lan
2025-07-26 12:57   ` Alex Elder
2025-07-26 18:00     ` Hendrik Hamerlinck

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