From patchwork Fri Jan 13 17:20:52 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: 9516071 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 1AC7F601E5 for ; Fri, 13 Jan 2017 17:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A145286E3 for ; Fri, 13 Jan 2017 17:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2D1F28763; Fri, 13 Jan 2017 17:21:23 +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 A9A9C286E3 for ; Fri, 13 Jan 2017 17:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750969AbdAMRVL (ORCPT ); Fri, 13 Jan 2017 12:21:11 -0500 Received: from mout.web.de ([212.227.17.12]:64220 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbdAMRVK (ORCPT ); Fri, 13 Jan 2017 12:21:10 -0500 Received: from [192.168.1.2] ([78.49.203.248]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LvBV8-1cbgFo2RAQ-010P2j; Fri, 13 Jan 2017 18:20:54 +0100 Subject: [PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() To: linux-spi@vger.kernel.org, Mark Brown References: <1413e173-dbac-7a6e-09cb-2287300a335e@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <5c46b68f-192e-2982-6a0e-2017da26f83d@users.sourceforge.net> Date: Fri, 13 Jan 2017 18:20:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <1413e173-dbac-7a6e-09cb-2287300a335e@users.sourceforge.net> X-Provags-ID: V03:K0:pBDd1xZdsjcfPyvhCnGTTeHxkadrbP4ihBu6FKcC9t+sKq0zqIw Ebj4eDO4aIho4PKoiisMhQVUlQ6pvBQYcIOPM50EasSwZ3Mk1imLuVR5Aj2DCrMKtoUSoJe /ByImrCXmGQQDf1XSsc4jbo83ErIQbsH2alChqay4xMDKu4r1pi1qN3gkc2U8ModVQmBkEm qiJLgbAwc9/0/iNusMf7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:8tIvzzwR3Nk=:3ve2mqR4ujCQToCoGZrMob h5o+zyid5FAxm+kSMMuhfcmTAJQj+H8ukT/gWlxyxB81gMectQm7LsxKhRLTOpeADNSg7tsY/ YOWX6KPwvHp8n0VuoV/uV3Typf8WcgcQDddHNIiglkk81SEbpNPBkxp9RW41KANqUfiVPNu05 3f6kY6DxyFgNRMJbcSudf0YL2/0qP34DIAFkrcGuCmfwgjJ9Q01Jt4o/OEBI/4CTXDtUaRs5Q D19RRrb7F1WjXRR8tRdZlNrB6vivCgYaLtxLxAQXLgy5OXxCt4B5ABuVAQyGEv+F+TDGOSnN9 fJBaFyfrmFcie4US7zWcydj41ibt/YMCkhxo+a8YmOEsiR42Ns19UYBtF06MfWwGJMEB/N0gL fnReBGvBg8znLwKrukTbcdQ+pyFrHQD53hH7KLGJHmtQTsJ5w0tm+UeMITSymKnrREKwhAcvT noIC4p0g8EgTidkGNLDbXfXYP0cc0+QPfNlZHlKmK0qmFtc42L+9Z9nops1ev9TC4t/gcMBAx 2cj7lNsmU8sTL6EH23tMl5LHBxLrU8Qa7ZaG5jOVLExKXmtN/0FN3yR9OWaULHOIeMcB51qRD neiTGuqxzpKwdNSdVgDx+xR84YkXAkNci1tFDjkwaQaDJ2dyP7+mLiwoUl6IhynD279+lDAVA T4DxouTxSnZQGGkw1cJd6SnQ/p10tggeTGAIAqxx4UYaViPjwK933q+XcEOAESvkHQucAFACg EgVAjA5Se/CJyxnnhrSm/cd2CuLOGOeGPyCXi3YtJXtKciyB2XoWFLroWckLFBJTcA5KihLvE +s0vo7C Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 13 Jan 2017 15:25:22 +0100 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data structure 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/spi/spi-topcliff-pch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index fcb991034c3d..0488b7c7cc19 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -1008,7 +1008,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) spin_unlock_irqrestore(&data->lock, flags); /* RX */ - dma->sg_rx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC); + dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC); sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_rx_p; @@ -1068,7 +1068,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) head = 0; } - dma->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC); + dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC); sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */ /* offset, length setting */ sg = dma->sg_tx_p;