From patchwork Mon Apr 17 20:55:16 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: 9684525 X-Patchwork-Delegate: agross@codeaurora.org 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 60AA160326 for ; Mon, 17 Apr 2017 20:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46E6025EA6 for ; Mon, 17 Apr 2017 20:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37FBE28334; Mon, 17 Apr 2017 20:55:40 +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 034BC25EA6 for ; Mon, 17 Apr 2017 20:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753860AbdDQUzh (ORCPT ); Mon, 17 Apr 2017 16:55:37 -0400 Received: from mout.web.de ([217.72.192.78]:51175 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752485AbdDQUzg (ORCPT ); Mon, 17 Apr 2017 16:55:36 -0400 Received: from [192.168.1.2] ([78.48.145.190]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0McFTf-1chrkU2az1-00JX4y; Mon, 17 Apr 2017 22:55:21 +0200 To: dmaengine@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Andy Gross , Dan Williams , David Brown , Sinan Kaya , Vinod Koul Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] hidma_mgmt_sys: Use devm_kmalloc_array() in hidma_mgmt_init_sys() Message-ID: <89811982-af2d-3ab3-0ab3-ddb6e4ca369f@users.sourceforge.net> Date: Mon, 17 Apr 2017 22:55:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:Wfg7hPUSFPyE0dHDbcB/AhZGODg/IqlnDE8yIw5xpGEUVPg/X+1 6BspzqOURt2Umuy0lAAWaSSmJ+ktyvyCg/WMK5ZqjxsqcO1cN53iT0eUr8WKWaxMYHJ2PQI 2NVLV4Q0hEzPTQqfzLNhpUedoECcuY3/OWbRG8aZvcoW/X7h2enqk+/1M0wFYt0iRhmNX9J wtMPHxMzYB3ZMnkYsG8bg== X-UI-Out-Filterresults: notjunk:1; V01:K0:xeU8Y5mTmqU=:Gs180K09YMNSTci8Mouhyg 4B0dHJIqMDsq90axMIAwtU0GuEoX54z+9DdcYfoZ7FD+vuld6TYKMl4ia5l7kVIkOWukEkFFf bweBSNfP99WtW0O/DR6w6VT8j6ejDKKlUcnIF0Q0YJZMEN/0DWHDqBZB5BjU+flv8gkQrL0qo 9vx9fQeXC4yM9DcGNfQN1qNlB/BdCu9mhhDONQKCBd+wuy6ItB69rUiRNuuR064RMFy2G6M94 +phqEWFpkY65CKKJRGGtTvjPc1RFztcwNyH+7t1l90SWR0RI5tpXcgkatPOrCo/GcBwoFqBPh K9WTwGXnX6iJhcxI/NE66cQpXdKpkmewUiUmtBSJ8jCS4JcxAL2c1OzeOVlFPLYDpFpceM/et eVD0+OWXAlDMdmdquNw1sGLeHkIDOM3IwhOEAzF/AYQw3pzYpPeOyPHxl1VJ+lFI0rlGOch9j gHqZNphpGLIJIe8BnLdGBBUaXLVb/cYHkKmPHUYvlpeRHEbuvRVE07hiN422FcfZjtLSi2GJb h45ajnj66Mw2TE1ilk+olIfaZCcKBqr2VvM9L8ELVuL6EcVua4i5aFHgSTqZh3/Acg8PxAJ3P 0jA1K68b7o/e5IrSLRY4vlbI8olM+ZSiTwBscTUMWHMn/suloT9IGUc/1Bps0VXIZT/OenqWo VMEGv1XmJ8Oi8VxDnGs9rzLh30Ti5HSaysLHydwcLc9GdBclSQdSG/IZWxrEj7IRrETdNCj40 T+1nwu/WjT8TUh/Tfep2wusy38JUGzxB6qIKuQ1ZnhJNIMsqq0R5/yBw05ObEIUWcU2KY7JjH Yv1Pq1R Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 17 Apr 2017 22:42:40 +0200 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kmalloc_array". This issue was detected by using the Coccinelle software. * Delete the local variable "required" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring Reviewed-by: Sinan Kaya --- drivers/dma/qcom/hidma_mgmt_sys.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dma/qcom/hidma_mgmt_sys.c b/drivers/dma/qcom/hidma_mgmt_sys.c index d61f1068a34b..e7222a0e9ba4 100644 --- a/drivers/dma/qcom/hidma_mgmt_sys.c +++ b/drivers/dma/qcom/hidma_mgmt_sys.c @@ -245,11 +245,12 @@ int hidma_mgmt_init_sys(struct hidma_mgmt_dev *mdev) { unsigned int i; int rc; - int required; struct kobject *chanops; - required = sizeof(*mdev->chroots) * mdev->dma_channels; - mdev->chroots = devm_kmalloc(&mdev->pdev->dev, required, GFP_KERNEL); + mdev->chroots = devm_kmalloc_array(&mdev->pdev->dev, + mdev->dma_channels, + sizeof(*mdev->chroots), + GFP_KERNEL); if (!mdev->chroots) return -ENOMEM;