Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625878 > unrolled thread

[PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-04-19 09:30 +0200
Last post2017-04-19 15:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-19 09:30 +0200
    Re: [PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe() Mark Rutland <mark.rutland@arm.com> - 2017-04-19 10:30 +0200
    Re: [PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe() Pawel Moll <pawel.moll@arm.com> - 2017-04-19 15:10 +0200

#1625878 — [PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-19 09:30 +0200
Subject[PATCH] bus: arm-ccn: Use devm_kcalloc() in arm_ccn_probe()
Message-ID<txSdQ-sj-3@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/bus/arm-ccn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 4d6a2b7e4d3f..6375bda0b2a1 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -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;
 
-- 
2.12.2

[toc] | [next] | [standalone]


#1625924

FromMark Rutland <mark.rutland@arm.com>
Date2017-04-19 10:30 +0200
Message-ID<txT9U-15G-13@gated-at.bofh.it>
In reply to#1625878
On Wed, Apr 19, 2017 at 09:29:24AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This looks reasonable to me. FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

I'll leave the final say to Pawel.

Mark.

> ---
>  drivers/bus/arm-ccn.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
> index 4d6a2b7e4d3f..6375bda0b2a1 100644
> --- a/drivers/bus/arm-ccn.c
> +++ b/drivers/bus/arm-ccn.c
> @@ -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;
>  
> -- 
> 2.12.2
> 

[toc] | [prev] | [next] | [standalone]


#1626100

FromPawel Moll <pawel.moll@arm.com>
Date2017-04-19 15:10 +0200
Message-ID<txXwS-3R5-23@gated-at.bofh.it>
In reply to#1625878
On Wed, 2017-04-19 at 09:29 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

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

Regards!

Pawel

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web