public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] clk: hisilicon: Improve deallocation in error path
@ 2026-03-03 15:25 J. Neuschäfer via B4 Relay
  2026-03-04 15:00 ` Brian Masney
  0 siblings, 1 reply; 4+ messages in thread
From: J. Neuschäfer via B4 Relay @ 2026-03-03 15:25 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Tao Lan, linux-clk, linux-kernel, J. Neuschäfer

From: "J. Neuschäfer" <j.ne@posteo.net>

Unmap 'base' if an error occurs after it has been mapped.

Reported-by: Tao Lan <taolan@huawei.com>
Closes: https://lore.kernel.org/lkml/ZNlSH+eWV8Sk3FYn@probook/
Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
---
Changes in v2:
- Rebase on v7.0-rc2
- Update my email address
- Reword the commit message somewhat
- Link to v1: https://lore.kernel.org/r/20240708-hisi-error-v1-1-727bc7399b63@gmx.net
---
 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 fae65127cd4aa8..08050ff1c8cf9a 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_obj(*clk_data);
 	if (!clk_data)
-		goto err;
+		goto err_base;
 
 	clk_data->base = base;
 	clk_table = kzalloc_objs(*clk_table, nr_clks);
@@ -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: 11439c4635edd669ae435eec308f4ab8a0804808
change-id: 20240329-hisi-error-c00ad7f8dd72

Best regards,
-- 
J. Neuschäfer <j.ne@posteo.net>



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

end of thread, other threads:[~2026-03-05 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 15:25 [PATCH v2] clk: hisilicon: Improve deallocation in error path J. Neuschäfer via B4 Relay
2026-03-04 15:00 ` Brian Masney
2026-03-05  9:02   ` J. Neuschäfer
2026-03-05 11:11     ` Brian Masney

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