From patchwork Fri Jan 13 17:14:45 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: 9516047 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 AF0EA601E5 for ; Fri, 13 Jan 2017 17:16:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3F928765 for ; Fri, 13 Jan 2017 17:16:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9342428767; Fri, 13 Jan 2017 17:16:33 +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 3A2F828765 for ; Fri, 13 Jan 2017 17:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbdAMRQa (ORCPT ); Fri, 13 Jan 2017 12:16:30 -0500 Received: from mout.web.de ([212.227.17.11]:52480 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbdAMRPc (ORCPT ); Fri, 13 Jan 2017 12:15:32 -0500 Received: from [192.168.1.2] ([78.49.203.248]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MPHC8-1cNhix1JS4-004P2z; Fri, 13 Jan 2017 18:14:47 +0100 Subject: [PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() 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: Date: Fri, 13 Jan 2017 18:14:45 +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:VY005jhjh2Fm5AEc4IMqbDxeHZFeNL/P2hnkSgbO/lO6RJ7Ig8B ogjg4EYpdYEa+25iViQD5D0ySWiLOO+5nmuxIYLJ9q/WQmev3qVVpzbBBfrngu9gfdvuvsH ni5nSI/H3eQXw+SQboyq9OKAG8BtBnI/362U0CKh82T8HFdi+iLHnEUHPcjELHDu9acVxye GtThtSt06QRsB2B53PfVg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Kerp0SQQtNY=:otf60o4ChziUdP1zkBOV/x q5CvtOP1pt3apJW+N00fTnm+3jyXmvEUaX0stT5Whbncf8BSFXyXSkvSzd3wkbQnk3C9uGFSE efmt638IEr7RtBFwhwJLgZ5GVt4ob9nWhcaGsVa/g6aKq4KZt/aNrQBIhA5dBx2b+LfpZHrDr 0tLjz5h169CQ1ZdhHj2lMZ9AJKh6+8Tpx8iGU2dKBQs5G0rk7/6BwTFUY5LJO7p7XDIPDRCQR /adAuX3RnFmQIU0eIdw+gu3BKMmc6EEHGEpCg0dAS5KISGTKVJjZ4/5nW4O3BoNudEhUvX4t3 I5HA3fWXRbYp9aq+7kVJRKM4mLG9J/mMl1ZTFzrBG1d3NKyOi5ncjw5HXKxFYsuorFKCrtwZj twEQP1NIVCnhPramXeiWu/K2TOXBHuLNOm1KS74vcMvZ8gmBvH0YIn1Y1slGYMdjzWdu3CDpn VgONQLs5XBUjfXp/y7XCJ4P2peWgYR8uc1akT9WRPIgEUyQmiVAjtuw7Bz3ZMhoFycK6xjvq7 oV7VGS0ZL3vvZ/U1KradOm2Xkeg9B/yXVkIv/a4/Y6U5oB5sfNogMbrawXpwaT2rvJ25FtiRp mvV1DVnNkWCcybdOh2AQunG9mHJ4O2hUQThG6/7qFjWxJwIkM1eiuZ3Rp8YPWiOTdx+beSBrW sgIDTWXBIgAhwGRwRa6jKqUIC4ZdtS5TwcHrxlgfrMa4SiBGUAfCDtlkWFe8yOgPSXoF5NCgq QUvo2v/ujNoYQoita5hwCuEhM8l9S5sf+KeFFSzNrcXG8G+LbzR4Y5JB8igbUp4T4OkIbPPb2 kOOlkTA 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 14:06:10 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/spi/spi-mpc52xx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c index c36002110c30..8cc129efe7ba 100644 --- a/drivers/spi/spi-mpc52xx.c +++ b/drivers/spi/spi-mpc52xx.c @@ -437,8 +437,9 @@ static int mpc52xx_spi_probe(struct platform_device *op) ms->gpio_cs_count = of_gpio_count(op->dev.of_node); if (ms->gpio_cs_count > 0) { master->num_chipselect = ms->gpio_cs_count; - ms->gpio_cs = kmalloc(ms->gpio_cs_count * sizeof(unsigned int), - GFP_KERNEL); + ms->gpio_cs = kmalloc_array(ms->gpio_cs_count, + sizeof(*ms->gpio_cs), + GFP_KERNEL); if (!ms->gpio_cs) { rc = -ENOMEM; goto err_alloc_gpio;