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


Groups > linux.kernel > #1628942 > unrolled thread

[PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-04-23 11:10 +0200
Last post2017-04-23 11:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-23 11:10 +0200

#1628942 — [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-23 11:10 +0200
Subject[PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()
Message-ID<tzlGN-6uj-3@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Apr 2017 10:30:32 +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.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

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

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 01e25c68dd5a..31a51ee1a910 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -845,8 +845,8 @@ static int k3_dma_probe(struct platform_device *op)
 		return -ENOMEM;
 
 	/* init phy channel */
-	d->phy = devm_kzalloc(&op->dev,
-		d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL);
+	d->phy = devm_kcalloc(&op->dev, d->dma_channels, sizeof(*d->phy),
+			      GFP_KERNEL);
 	if (d->phy == NULL)
 		return -ENOMEM;
 
@@ -875,8 +875,8 @@ static int k3_dma_probe(struct platform_device *op)
 	d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES;
 
 	/* init virtual channel */
-	d->chans = devm_kzalloc(&op->dev,
-		d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL);
+	d->chans = devm_kcalloc(&op->dev, d->dma_requests, sizeof(*d->chans),
+				GFP_KERNEL);
 	if (d->chans == NULL)
 		return -ENOMEM;
 
-- 
2.12.2

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web