[PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common()
xkernel.wang at foxmail.com
xkernel.wang at foxmail.com
Thu Apr 7 02:28:23 PDT 2022
From: Xiaoke Wang <xkernel.wang at 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 at 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;
}
--
More information about the linux-arm-kernel
mailing list