From: SF Markus Elfring <elfring@users.sourceforge.net>
To: dmaengine@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Vinod Koul <vinod.koul@intel.com>,
Zhangfei Gao <zhangfei.gao@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe()
Date: Sun, 23 Apr 2017 11:07:43 +0200 [thread overview]
Message-ID: <3f5acfa7-3c12-e8e1-17dd-ae03ce45c0be@users.sourceforge.net> (raw)
In-Reply-To: <f83beedc-28fd-c373-cca8-7261e42577a5@users.sourceforge.net>
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
next prev parent reply other threads:[~2017-04-23 9:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-23 9:06 [PATCH 0/2] dmaengine: k3dma: Fine-tuning for five function implementations SF Markus Elfring
2017-04-23 9:07 ` SF Markus Elfring [this message]
2017-04-23 9:09 ` [PATCH 2/2] dmaengine: k3dma: Adjust six checks for null pointers SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f5acfa7-3c12-e8e1-17dd-ae03ce45c0be@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.com \
--cc=zhangfei.gao@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox