Skip to contentSkip to conversation

clk: hisilicon: reset: Use kzalloc instead of kmalloc

PATCH In review Shawn Guo 3 participants 3 messages Feb 24 – Feb 26 Common clk

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/1 clk: hisilicon: reset: Use kzalloc instead of kmalloc

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.

---
 drivers/clk/hisilicon/reset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/hisilicon/reset.c +1 -1
index 93cee17db8b1..c3b7daac9313 100644
@@ -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;
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · 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.

Quoted 8 lines
	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.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Shawn Guo
Quoted 11 lines · 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.

Fixes 97b7129cd2af ("reset: hisilicon: change the definition of hisi_reset_init")
Quoted 10 lines
---
 drivers/clk/hisilicon/reset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/hisilicon/reset.c +0 -0
index 93cee17db8b1..c3b7daac9313 100644

drivers/clk/hisilicon/reset.c struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev) · line 97

Quoted 8 lines
drivers/clk/hisilicon/reset.c +1 -1
@@ -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;
 

regards
Philipp