From patchwork Sat Apr 22 20:31:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9694479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 388A1601E9 for ; Sat, 22 Apr 2017 20:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2982026BE9 for ; Sat, 22 Apr 2017 20:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B0CD27FBE; Sat, 22 Apr 2017 20:31:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0F3826BE9 for ; Sat, 22 Apr 2017 20:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427130AbdDVUbi (ORCPT ); Sat, 22 Apr 2017 16:31:38 -0400 Received: from mout.web.de ([212.227.15.4]:53572 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427128AbdDVUbh (ORCPT ); Sat, 22 Apr 2017 16:31:37 -0400 Received: from [192.168.1.2] ([77.181.100.232]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LkyXt-1cTVgd3QXt-00anFd; Sat, 22 Apr 2017 22:31:31 +0200 Subject: [PATCH 1/2] dmaengine: zx: Use devm_kcalloc() in zx_dma_probe() From: SF Markus Elfring To: dmaengine@vger.kernel.org, Dan Williams , Shawn Guo , Vinod Koul Cc: LKML , kernel-janitors@vger.kernel.org References: <85b8d46d-1643-0fdd-b295-9359ebca6444@users.sourceforge.net> Message-ID: Date: Sat, 22 Apr 2017 22:31:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <85b8d46d-1643-0fdd-b295-9359ebca6444@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:Fd65Mae3vxwzHzqPSZHBs4hiun62vfBEcrBgBylMzbPIRLgjXoT u+KVfr1KBksKanfsRsZDuzq63M3MIO7UWCiabA1nOHDJGfaaXeKuJGuUYNg8rF9DK4f+nG0 Nj0kOWpf2c6tDG0mFF7Qm2cPoOIAZS8sK3fCZBYbpTp2trDoNwiCEUQMfLwQenuRCnooRt5 m22T7LygIVhF/dH0gTXsQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:E9q8h/+9p2k=:U9LUrgddEnN/3BxBoTuRQY 7jP/ERJyJK4kG0GrlAR5jmYlW67pDraM1vrgQjvjKTWSTgeiPYSBco8VKAeVpYWeGOPsurWZZ oaVDuwfpDTkrmY2Z0NMn0kt/wwDqUUCjovHkfiFD1Klmh7qSv/hJHDgo7QU6W1EtYtCuumU7y IT8BfTfujWuvZ2flfoPiYeshvQBwLB9TgWMy0rV2JOswpk3nKgcljf5h24BHW5JegTyTt6PfF fjFW3ioB1CnHFTGF0q1WREcOl4dOekW44Qcr2l4KAVTZo9+Vlt1qLi3EULVlW7q5YeXn22NZs Y+HrZmj3h1B83HiSvtMks1klWG4CBI+LMueK+5Um17Kb/j2VaeMZAcEdL4jziPr9SqOsAwZZS OJnYMxBRBhjhIynW4CDD92Hcxo512EKkfZ62TBljpqTVP+sZFv3N3zkHP0aBIo6gmqvpthiMO aB7Oh30t563VCp7NM8JrGgbVU//i4VSl3+6zN8E6vesH0pxAi96yQnf+SRi2ZMuUaKPK3+fda wSYO3PSmIExbk/zFEll1R0fGYFDQLqPgka/5MRLbkiwZfVunJ8I8pOT0lcRar/iYIVQ9VsRyq +s543rHQA3ZkixagC47RjYbc/wsgJPBoGLzmpxweP7MGdfyXDEFLEIXcaK5woHpJiS5OBpXHy zHQ0SSUFoScHGG1ZUT69lnlzA1CajS6bz/Lv7ifXVwF/bm4XL+77noS7guoqHMHIC96TiwH0J ygDy3DMARJYjwz0x64CKmgNUpgbfGiiJZRg0Qnqe9a8cFivkBtJV87KehZ4UHMaSewFYF7tet +AW+8yN Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 22 Apr 2017 22:00:10 +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 --- drivers/dma/zx_dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c index 2bb695315300..4f7587a100ea 100644 --- a/drivers/dma/zx_dma.c +++ b/drivers/dma/zx_dma.c @@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op) return -ENOMEM; /* init phy channel */ - d->phy = devm_kzalloc(&op->dev, - d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL); + d->phy = devm_kcalloc(&op->dev, d->dma_channels, sizeof(*d->phy), + GFP_KERNEL); if (!d->phy) return -ENOMEM; @@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op) d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; /* init virtual channel */ - d->chans = devm_kzalloc(&op->dev, - d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL); + d->chans = devm_kcalloc(&op->dev, d->dma_requests, sizeof(*d->chans), + GFP_KERNEL); if (!d->chans) return -ENOMEM;