[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_FE734C50BC851F2AB5FE1380F833A7E67A0A@qq.com>
Date: Thu, 7 Apr 2022 17:28:23 +0800
From: xkernel.wang@...mail.com
To: narmstrong@...libre.com, jbrunet@...libre.com,
mturquette@...libre.com, sboyd@...nel.org, khilman@...libre.com
Cc: martin.blumenstingl@...glemail.com, p.zabel@...gutronix.de,
linux-amlogic@...ts.infradead.org, linux-clk@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common()
From: Xiaoke Wang <xkernel.wang@...mail.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@...mail.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;
}
--
Powered by blists - more mailing lists