public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc
@ 2026-02-24  2:19 Shawn Guo
  2026-02-25 22:39 ` Brian Masney
  2026-02-26  8:33 ` Philipp Zabel
  0 siblings, 2 replies; 3+ messages in thread
From: Shawn Guo @ 2026-02-24  2:19 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Michael Turquette, Philipp Zabel, linux-clk, linux-kernel,
	Shawn Guo

With commit c721f189e89c ("reset: Instantiate reset GPIO controller for
shared reset-gpios") in place, the call sequence hisi_reset_init() ->
reset_controller_register() starts failing on Hi3798CV200 Poplar platform,
due to the new check added by the commit above.

	if (rcdev->of_node && rcdev->of_args)
		return -EINVAL;

The failure is caused by that hisi_reset_init() allocates memory for rcdev
without zeroing it out.  Fix the issue by using kzalloc instead of
kmalloc for memory allocation.

Signed-off-by: Shawn Guo <shawnguo@kernel.org>
---
 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.47.3


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

* Re: [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc
  2026-02-24  2:19 [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc Shawn Guo
@ 2026-02-25 22:39 ` Brian Masney
  2026-02-26  8:33 ` Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Masney @ 2026-02-25 22:39 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Stephen Boyd, Michael Turquette, Philipp Zabel, linux-clk,
	linux-kernel

On Tue, Feb 24, 2026 at 10:19:12AM +0800, Shawn Guo wrote:
> With commit c721f189e89c ("reset: Instantiate reset GPIO controller for
> shared reset-gpios") in place, the call sequence hisi_reset_init() ->
> reset_controller_register() starts failing on Hi3798CV200 Poplar platform,
> due to the new check added by the commit above.
> 
> 	if (rcdev->of_node && rcdev->of_args)
> 		return -EINVAL;
> 
> The failure is caused by that hisi_reset_init() allocates memory for rcdev
> without zeroing it out.  Fix the issue by using kzalloc instead of
> kmalloc for memory allocation.
> 
> Signed-off-by: Shawn Guo <shawnguo@kernel.org>

Reviewed-by: Brian Masney <bmasney@redhat.com>


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

* Re: [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc
  2026-02-24  2:19 [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc Shawn Guo
  2026-02-25 22:39 ` Brian Masney
@ 2026-02-26  8:33 ` Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2026-02-26  8:33 UTC (permalink / raw)
  To: Shawn Guo, Stephen Boyd; +Cc: Michael Turquette, linux-clk, linux-kernel

On Di, 2026-02-24 at 10:19 +0800, Shawn Guo wrote:
> With commit c721f189e89c ("reset: Instantiate reset GPIO controller for
> shared reset-gpios") in place, the call sequence hisi_reset_init() ->
> reset_controller_register() starts failing on Hi3798CV200 Poplar platform,
> due to the new check added by the commit above.
> 
> 	if (rcdev->of_node && rcdev->of_args)
> 		return -EINVAL;
> 
> The failure is caused by that hisi_reset_init() allocates memory for rcdev
> without zeroing it out.  Fix the issue by using kzalloc instead of
> kmalloc for memory allocation.

Fixes: 97b7129cd2af ("reset: hisilicon: change the definition of hisi_reset_init")

> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
> ---
>  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;
>  

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

end of thread, other threads:[~2026-02-26  8:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24  2:19 [PATCH] clk: hisilicon: reset: Use kzalloc instead of kmalloc Shawn Guo
2026-02-25 22:39 ` Brian Masney
2026-02-26  8:33 ` Philipp Zabel

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