From patchwork Sun Aug 28 09:50:20 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: 9302615 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 B16B4607D6 for ; Sun, 28 Aug 2016 09:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9182C288B4 for ; Sun, 28 Aug 2016 09:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E7E228937; Sun, 28 Aug 2016 09:50:36 +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 56314288B4 for ; Sun, 28 Aug 2016 09:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755295AbcH1Jue (ORCPT ); Sun, 28 Aug 2016 05:50:34 -0400 Received: from mout.web.de ([212.227.15.14]:58402 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755236AbcH1Jud (ORCPT ); Sun, 28 Aug 2016 05:50:33 -0400 Received: from [192.168.1.3] ([77.181.152.74]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0Lw0vl-1b3oY73PZt-017ntF; Sun, 28 Aug 2016 11:50:22 +0200 To: linux-parisc@vger.kernel.org, Helge Deller , "James E. J. Bottomley" Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Subject: [PATCH] PA-RISC-inventory: Use kmalloc_array() in add_system_map_addresses() Message-ID: Date: Sun, 28 Aug 2016 11:50:20 +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:EICsjCOs8ZbhJuQOQVuEWaWjF7FMbliha2Ms6nem3jDb+WcQUwd n+1kevmiyvAkn86V4YqLSYVfL7yovo0MuaSXDuqB9I6uRbR1aXOvMSXD01cIhWqcSEHHk/K nGvzMHqWYMY04nuc6xUXB5RFQpdfEsbRYJ+enbcFBLWIKO1OUh0pXO6/v7vM3DXPfmawXUW pMWJ4QK5i2QdbUfFpIE8w== X-UI-Out-Filterresults: notjunk:1; V01:K0:tg/YUnGm0Bw=:1SlKl8DHSUDBVbHnn4mucL TPXVauCNvXNQKmJA5vXWlcp8/snRs09noB10yBet2bMCCRXwggTMSqtfrAzNfu4+fEUd/Bhco KlOgxJPPEFLhDNODPT1jJZll9HA45LBV9fMjrxTf7A0Xlux/R+gjbvWslpLp706PiHH6LAbXF GCcjOHM6nDY/VzqDm1eQ8/Az1ijDNX0LIlvzNR+mESsPPhaPcm8soB59irLyobaHEZAp5RlOA mA1+/Q2mX0zLZoCWF2lX+rlIxkgSdVaKV5fxBoRTUqMDUiFoVX9FtHuH67EPoGcj8EiPwLahg L1RRNnaxDsuSYVshQKvuewtfVoTPa+fvubNM1+QUPp0AIN0OcxE1hZi7QlRaHwtSOJcYJOKS5 U6IqOoxg8y4S2AGD9mJqvSBlb1UK1gnJsS5bg7SXGOGg3zWLh11wlg5tdfcGD060S3G1+feWj jxGKnSA6OnrWd4kB4Nx2rHOKHt+EynM6TZvihIRphSvhIEuZpUMQF288gdJgM+PNa/XqQ1kQF 96vHQOyiT80KbSgRayfvVeMfQv12QwTolbl7fhXm27M3sx+Oo1c0ds6e1uKRV3V+ET0IllCuu uqL+aKMyY5wHIkdBZ2mLeMPwZHQ5EnYI9UlBgC1bH4uJ/mLb/U29sluPFn3Hr7xVDgqpPI+bt DStmxmXLBKCcKQ2q9mEFbKGy8zjmXfzivVuCaKMb12wieqdDOwCBhdEw17JXTQOS0KE8Po4cd A0MirvfU5P3ea0GoJWAP+7UtxNIxzl+3XLGuLyQ5iJyi8RRAJwGaevWqGYlmfBaVXSY+AP7Ae o58SnAC Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 28 Aug 2016 11:40:53 +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/parisc/kernel/inventory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c index f0b6722..545f9d2 100644 --- a/arch/parisc/kernel/inventory.c +++ b/arch/parisc/kernel/inventory.c @@ -506,7 +506,7 @@ add_system_map_addresses(struct parisc_device *dev, int num_addrs, long status; struct pdc_system_map_addr_info addr_result; - dev->addr = kmalloc(num_addrs * sizeof(unsigned long), GFP_KERNEL); + dev->addr = kmalloc_array(num_addrs, sizeof(*dev->addr), GFP_KERNEL); if(!dev->addr) { printk(KERN_ERR "%s %s(): memory allocation failure\n", __FILE__, __func__);