mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common()
@ 2022-04-07  9:28 xkernel.wang
  2022-04-07 10:05 ` Philipp Zabel
  2022-04-18 16:39 ` Martin Blumenstingl
  0 siblings, 2 replies; 5+ messages in thread
From: xkernel.wang @ 2022-04-07  9:28 UTC (permalink / raw)
  To: narmstrong, jbrunet, mturquette, sboyd, khilman
  Cc: martin.blumenstingl, p.zabel, linux-amlogic, linux-clk,
	linux-arm-kernel, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

`rstc` is allocated by kzalloc() for resetting the controller register,
however, if reset_controller_register() fails, `rstc` is not properly
released before returning, which can lead to memory leak.
Therefore, this patch adds kfree(rstc) on the above error path.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 drivers/clk/meson/meson8b.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
index a844d35..823eacc 100644
--- a/drivers/clk/meson/meson8b.c
+++ b/drivers/clk/meson/meson8b.c
@@ -3741,6 +3741,7 @@ static void __init meson8b_clkc_init_common(struct device_node *np,
 	if (ret) {
 		pr_err("%s: Failed to register clkc reset controller: %d\n",
 		       __func__, ret);
+		kfree(rstc);
 		return;
 	}
 
-- 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2022-04-24 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07  9:28 [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common() xkernel.wang
2022-04-07 10:05 ` Philipp Zabel
2022-04-18 16:39 ` Martin Blumenstingl
2022-04-23  2:25   ` Stephen Boyd
2022-04-24 19:36     ` Martin Blumenstingl

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

all inboxes | Powered by JetHome®