[PATCH] clk: hisilicon: Improve deallocation in error path
From: Jonathan Neuschäfer
Date: Sun Jul 07 2024 - 19:46:51 EST
The error handling in hisi_clk_init doesn't deallocate (unmap) the
'base' mapping if an error happens later in the function.
Reported-by: Tao Lan <taolan@xxxxxxxxxx>
Closes: https://lore.kernel.org/lkml/ZNlSH+eWV8Sk3FYn@probook/
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>
---
drivers/clk/hisilicon/clk.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c
index 09368fd32befb3..72aad24a5ebb26 100644
--- a/drivers/clk/hisilicon/clk.c
+++ b/drivers/clk/hisilicon/clk.c
@@ -70,7 +70,7 @@ struct hisi_clock_data *hisi_clk_init(struct device_node *np,
clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
if (!clk_data)
- goto err;
+ goto err_base;
clk_data->base = base;
clk_table = kcalloc(nr_clks, sizeof(*clk_table), GFP_KERNEL);
@@ -83,6 +83,8 @@ struct hisi_clock_data *hisi_clk_init(struct device_node *np,
return clk_data;
err_data:
kfree(clk_data);
+err_base:
+ iounmap(base);
err:
return NULL;
}
---
base-commit: 22a40d14b572deb80c0648557f4bd502d7e83826
change-id: 20240329-hisi-error-c00ad7f8dd72
Best regards,
--
Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>