Skip to contentSkip to conversation

bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe()

PATCH In review SF Markus Elfring 3 participants 3 messages Apr 19, 2017 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 09:12:43 +0200

Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

---
 drivers/bus/arm-ccn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/arm-ccn.c +4 -4
index 4d6a2b7e4d3f..6375bda0b2a1 100644
@@ -1520,10 +1520,10 @@ static int arm_ccn_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
-	ccn->node = devm_kzalloc(ccn->dev, sizeof(*ccn->node) * ccn->num_nodes,
-		GFP_KERNEL);
-	ccn->xp = devm_kzalloc(ccn->dev, sizeof(*ccn->node) * ccn->num_xps,
-		GFP_KERNEL);
+	ccn->node = devm_kcalloc(ccn->dev, ccn->num_nodes, sizeof(*ccn->node),
+				 GFP_KERNEL);
+	ccn->xp = devm_kcalloc(ccn->dev, ccn->num_xps, sizeof(*ccn->node),
+			       GFP_KERNEL);
 	if (!ccn->node || !ccn->xp)
 		return -ENOMEM;
 
Signature · 1 line
2.12.2
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 09:12:43 +0200

Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

This looks reasonable to me. FWIW:

I'll leave the final say to Pawel.

Mark.

Quoted 26 lines
---
 drivers/bus/arm-ccn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/bus/arm-ccn.c +4 -4
index 4d6a2b7e4d3f..6375bda0b2a1 100644
@@ -1520,10 +1520,10 @@ static int arm_ccn_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
-	ccn->node = devm_kzalloc(ccn->dev, sizeof(*ccn->node) * ccn->num_nodes,
-		GFP_KERNEL);
-	ccn->xp = devm_kzalloc(ccn->dev, sizeof(*ccn->node) * ccn->num_xps,
-		GFP_KERNEL);
+	ccn->node = devm_kcalloc(ccn->dev, ccn->num_nodes, sizeof(*ccn->node),
+				 GFP_KERNEL);
+	ccn->xp = devm_kcalloc(ccn->dev, ccn->num_xps, sizeof(*ccn->node),
+			       GFP_KERNEL);
 	if (!ccn->node || !ccn->xp)
 		return -ENOMEM;
 
Signature · 1 line
2.12.2
#2 lore raw
In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 09:12:43 +0200

Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

Fine with me. I'll queue it with a couple other CCN driver changes. Will probably get into 4.13.

Regards!

Pawel