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

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