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

* Re: [PATCH] clk: hisilicon: reset: Use devm_kzalloc to initialize hisi_reset_controller
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Masney @ 2026-05-11 15:09 UTC (permalink / raw)
  To: Min zhang
  Cc: Wei Xu, Michael Turquette, Stephen Boyd, Philipp Zabel, linux-clk,
	linux-kernel

On Mon, May 11, 2026 at 01:32:14PM +0800, Min zhang wrote:
> 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

This is not a valid fixes tag. Please drop.

> 
> Signed-off-by: Min zhang <zhangmin2026@yeah.net>

Fixes: 97b7129cd2afb ("reset: hisilicon: change the definition of hisi_reset_init")
Reviewed-by: Brian Masney <bmasney@redhat.com>


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

* [PATCH v2] clk: hisilicon: reset: Use devm_kzalloc to initialize hisi_reset_controller
  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 ` Min zhang
  2026-05-11 17:50   ` Brian Masney
  1 sibling, 1 reply; 4+ messages in thread
From: Min zhang @ 2026-05-11 17:04 UTC (permalink / raw)
  To: Wei Xu, Michael Turquette, Stephen Boyd, Brian Masney,
	Philipp Zabel, Min zhang, Jiancheng Xue, 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: 97b7129cd2afb ("reset: hisilicon: change the definition of hisi_reset_init")

Reviewed-by: Brian Masney <bmasney@redhat.com>
Signed-off-by: Min zhang <zhangmin2026@yeah.net>
---
Changes in v2:
- Drop the invalid fixes tag and use the standard format.
- Add Reviewed-by tag from Brian Masney.
 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

* Re: [PATCH v2] clk: hisilicon: reset: Use devm_kzalloc to initialize hisi_reset_controller
  2026-05-11 17:04 ` [PATCH v2] " Min zhang
@ 2026-05-11 17:50   ` Brian Masney
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Masney @ 2026-05-11 17:50 UTC (permalink / raw)
  To: Min zhang
  Cc: Wei Xu, Michael Turquette, Stephen Boyd, Philipp Zabel,
	Jiancheng Xue, linux-clk, linux-kernel

Hi Min,

On Tue, May 12, 2026 at 01:04:14AM +0800, Min zhang wrote:
> 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: 97b7129cd2afb ("reset: hisilicon: change the definition of hisi_reset_init")
> 
> Reviewed-by: Brian Masney <bmasney@redhat.com>
> Signed-off-by: Min zhang <zhangmin2026@yeah.net>

There's no newline between the Fixes and the other tags. Take a look at
'git log' and look at the other commits.

Sorry for the trivial ask, but it's important to keep things like this
consistent across the kernel.

Brian


^ permalink raw reply	[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