public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create() error path
@ 2026-04-12 12:42 Guangshuo Li
  2026-04-13  8:04 ` Théo Lebrun
  2026-04-13 16:42 ` Brian Masney
  0 siblings, 2 replies; 6+ messages in thread
From: Guangshuo Li @ 2026-04-12 12:42 UTC (permalink / raw)
  To: Vladimir Kondratiev, Gregory CLEMENT, Théo Lebrun,
	Michael Turquette, Stephen Boyd, linux-mips, linux-clk,
	linux-kernel
  Cc: Guangshuo Li, stable

eqc_auxdev_create() allocates an auxiliary_device with kzalloc() before
calling auxiliary_device_init().

When auxiliary_device_init() returns an error, the function exits
without freeing adev. Since the release callback is only expected to
handle cleanup after successful initialization, adev should be freed
explicitly in this path.

Add the missing kfree(adev) before returning from the
auxiliary_device_init() error path.

Fixes: 25d904946a0b ("clk: eyeq: add driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/clk/clk-eyeq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index ea1c3d78e7cd..a48ecec4c9a5 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -346,8 +346,10 @@ static int eqc_auxdev_create(struct device *dev, void __iomem *base,
 	adev->id = id;
 
 	ret = auxiliary_device_init(adev);
-	if (ret)
+	if (ret) {
+		kfree(adev);
 		return ret;
+	}
 
 	ret = auxiliary_device_add(adev);
 	if (ret)
-- 
2.43.0


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

end of thread, other threads:[~2026-04-14 20:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 12:42 [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create() error path Guangshuo Li
2026-04-13  8:04 ` Théo Lebrun
2026-04-14 11:51   ` Guangshuo Li
2026-04-13 16:42 ` Brian Masney
2026-04-14 11:49   ` Guangshuo Li
2026-04-14 20:06     ` Brian Masney

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