From patchwork Sun Apr 23 09:07:43 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: 9694611 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 D312360245 for ; Sun, 23 Apr 2017 09:07:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6ABA26E56 for ; Sun, 23 Apr 2017 09:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B823427F94; Sun, 23 Apr 2017 09:07:58 +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 3C7E626E56 for ; Sun, 23 Apr 2017 09:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1044313AbdDWJH4 (ORCPT ); Sun, 23 Apr 2017 05:07:56 -0400 Received: from mout.web.de ([212.227.15.4]:49774 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1044312AbdDWJHx (ORCPT ); Sun, 23 Apr 2017 05:07:53 -0400 Received: from [192.168.1.2] ([77.182.27.214]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MCIUL-1cteu801fl-009D1m; Sun, 23 Apr 2017 11:07:45 +0200 Subject: [PATCH 1/2] dmaengine: k3dma: Use devm_kcalloc() in k3_dma_probe() From: SF Markus Elfring To: dmaengine@vger.kernel.org, Dan Williams , Vinod Koul , Zhangfei Gao Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <3f5acfa7-3c12-e8e1-17dd-ae03ce45c0be@users.sourceforge.net> Date: Sun, 23 Apr 2017 11:07:43 +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: Content-Language: en-GB X-Provags-ID: V03:K0:xTmSNiFS2rafHGRx/hTXlVla2zzWz5Y8y6KF5g1f+ajO2n0z0ad +ImWV46nikgOvC3eUb3tYLmFSX0baEzz5U8Q65zXC1Vy8iZRECFQWlsOm7PFMFrZhssZkmz pD10gCaQFZYSqwFbRkD351BcusQ5nisouSuPRrEa9RVzA8h2T5GXifVOAZJpW8970g+tyxJ r08Rw2XH/eLwSuLTjRcOw== X-UI-Out-Filterresults: notjunk:1; V01:K0:O9S8MDLM69Q=:PvTPXh4O+IDTT0mYODiWMn dPsJly6cv8tFs2xKpLK/BXDLK7rmRGvwnNvzDU9gQluCFwlnHijBaBrFj7QO7SMCCZq+pJ21x 0Ch7rZjqMe/BGuBaGKzcz0n5LK5ahShmONWbnvDeEIBLa0s0xAjmGgsAXdGi2TFBJ/lYeQdPn OZjKd6bhEP8TCTqs/4PzIWA2uH6WwvSO/8RO9C4G2etD/Mw66RfIL76LkF9AguoLe7UH+oBTL BjF35mOs02KOrDYXAVopVZq+dt98ZwXYUN7HC9sWsKT0yqTAmvO+C3uGQFHIbb4vVXHVvb3gw +GIFQ5LHoogm+2w7bkOla8tDs6fziR+ihpgy8ObQkRHFF4FRfw1imOr/7fs6HwyWmVoG1HVYV cfAQHj30rhYyEGBtnh2geVCjeuElG3qfVJm3D/VH/7gnWpK+jJfUG2KMzKvbvg0PpGhLNkMGT vY7BEc8gq8Z0auYB4DQuoEOBHzCYteGhk4mD+vfFBLI00+JpPH9Mb4aU0RFoDHD6NSjC1BwHe 0LsxGn2eue1PMSlo+dvvPtA4oh76L0hkQ2093+MzW/8i3oFyjGnWhAs6ArQJd0HSmS1MIsgcC XdUErdGJ6eLnB4JIOJ0glBDPVYLrmTax91/+gLPXlQ9VnsheEgREUAcQ/PvZ0mNJB9zQJhoRU 8gSjoaSfpSXQ9wq0riowRXwtFYhSyUtq+U1rUK3vIPxtWDkHbOIjXAfa8mWWKq559ZwTstKDG DLonz/nDeLec3BtQAyfvYKJE2W05CZppROm6hMSQ0nZi+FedTIcYzFYF4R2QjaOz3qN3hZG41 3A3xmhj 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: 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 --- 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;