The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] clk: hisilicon: reset: Use devm_kzalloc to initialize hisi_reset_controller
@ 2026-05-11  5:32 Min zhang
  2026-05-11 15:09 ` Brian Masney
  2026-05-11 17:04 ` [PATCH v2] " Min zhang
  0 siblings, 2 replies; 4+ messages in thread
From: Min zhang @ 2026-05-11  5:32 UTC (permalink / raw)
  To: Wei Xu, Michael Turquette, Stephen Boyd, Brian Masney,
	Philipp Zabel, Min zhang, linux-clk, linux-kernel

Using devm_kmalloc() does not zero-initialize the allocated structure.
Uninitialized members in struct hisi_reset_controller may contain garbage
data, which can cause reset_controller_register() to fail unexpectedly.

Replace devm_kmalloc() with devm_kzalloc() to ensure all structure fields
are properly zero-initialized.

Fixes: reset controller registration failure due to invalid dirty data

Signed-off-by: Min zhang <zhangmin2026@yeah.net>
---
 drivers/clk/hisilicon/reset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/hisilicon/reset.c b/drivers/clk/hisilicon/reset.c
index 93cee17db8b1..c3b7daac9313 100644
--- a/drivers/clk/hisilicon/reset.c
+++ b/drivers/clk/hisilicon/reset.c
@@ -91,7 +91,7 @@ struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev)
 {
 	struct hisi_reset_controller *rstc;
 
-	rstc = devm_kmalloc(&pdev->dev, sizeof(*rstc), GFP_KERNEL);
+	rstc = devm_kzalloc(&pdev->dev, sizeof(*rstc), GFP_KERNEL);
 	if (!rstc)
 		return NULL;
 
-- 
2.34.1


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11  5:32 [PATCH] clk: hisilicon: reset: Use devm_kzalloc to initialize hisi_reset_controller Min zhang
2026-05-11 15:09 ` Brian Masney
2026-05-11 17:04 ` [PATCH v2] " Min zhang
2026-05-11 17:50   ` Brian Masney

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