From patchwork Thu Aug 25 16:07:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9299539 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 E2BC660459 for ; Thu, 25 Aug 2016 16:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33FB29267 for ; Thu, 25 Aug 2016 16:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C729629381; Thu, 25 Aug 2016 16:09:24 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 588F529267 for ; Thu, 25 Aug 2016 16:09:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcxC4-0004g0-55; Thu, 25 Aug 2016 16:07:52 +0000 Received: from mout.web.de ([212.227.15.14]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcxBw-0004HQ-NL for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2016 16:07:45 +0000 Received: from [192.168.1.3] ([78.49.16.254]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LnjAt-1avLtr3WDH-00hvC0; Thu, 25 Aug 2016 18:07:09 +0200 To: linux-arm-kernel@lists.infradead.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King From: SF Markus Elfring Subject: [PATCH] ARM: pxa: Use kmalloc_array() in pxa_pm_init() Message-ID: <49864e7d-f786-9739-6d8c-4480ce228830@users.sourceforge.net> Date: Thu, 25 Aug 2016 18:07:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:7rVRCxGcAJCojmmG0RilvkIfgf+rYR6SU56DsV9kesG4rMKgrCz 6aK1pgU7I0tolnkDXOzNico4luEiilkfqj8HaPMpTiS34e7LbrK7EP/iSWO11/XIf7TmnuZ 34caxwAIQ1vsAeN7Xu4OZZQVv58b+NX38D4LDCVVQ+UfjG0zTrD+gZ9FFey+7NbX8MfFEMb 432xBdG40yldXuLaZRkug== X-UI-Out-Filterresults: notjunk:1; V01:K0:A0kv8Zxho8c=:5hU4L1QtVEbIl865VYUe3v g0+9iLSMATzeL2DGG5+Y7pwGHHlql9nKFbATVuxVAvBXYT+v/37EedTRfBeZ9KoxsCKQn1ojs pd39mZj5KvrC/9Iq5aK8mPE4juJMtpyiPWhWEq/tMbwYhUUFSW0JQFvMm4enrnNgVT46VMmwv NheowhrsUH/xwBlzzFCO46rguF0KJPTnGr93LD9nDf+9/qKOOqpPqPioPEEyCrsDddk6DE3SZ LKE9nDNtr8lVIJwR5lzg55I/M+A74KfjakYh2ogaeWxNZRhEgsrqGvE1a78ths258AZfM5MDZ l3rIXctY01QUfjBPzOcvgQOvVP+03b77UfGde7Ak+/008CSxLLSJNfMjz1+Zn1r8GWUr2bCiT BKuuw3EMLa7cHoM2ptjbFeU9MjPWuY0ENhk7D2+sBROAC0xXmrZBOKZynHBPDqzqP0XctXNsw l9x9tMzuW0krWU45wFelhkgLbH/ZTPOofiBXB7qPgwfPQe0icHQs9W2afdY5XvR1dxQcutgGr Tuv/AeZnlWxLT2C68/pnp0a5MUH9g599TjP7rr0nAXQge8Ui7N5j2ErFFELr2DKoSAMr1E9Au edcwrWLyXXvoB1YUQk17d3sjDqRVZZ2neJgcuHvIkU4pgyDGaRe0MIIqIvgxuDpQWyBk7WRsw 2m+9jmiIUqtkzcuB1Ept0x7Bz27cxM1QU1GqqkvNczv3C6Ak34ynm9+IKX8njLY30+enPIpIn F7j/zYfPP5WS07cT0r86wzwMfoGVo0pI5sseodM4vwzhyfZFmE4iYdgOs32HWTA9Hxfth/Jup AY20en4VfYzzQHqXTCMP/QoFV40Dg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160825_090745_160314_BCF1FDDC X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML , Paolo Bonzini Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 25 Aug 2016 18:01:37 +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 "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 --- arch/arm/mach-pxa/pm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c index 388463b..e7450fb 100644 --- a/arch/arm/mach-pxa/pm.c +++ b/arch/arm/mach-pxa/pm.c @@ -104,8 +104,9 @@ static int __init pxa_pm_init(void) return -EINVAL; } - sleep_save = kmalloc(pxa_cpu_pm_fns->save_count * sizeof(unsigned long), - GFP_KERNEL); + sleep_save = kmalloc_array(pxa_cpu_pm_fns->save_count, + sizeof(*sleep_save), + GFP_KERNEL); if (!sleep_save) { printk(KERN_ERR "failed to alloc memory for pm save\n"); return -ENOMEM;