From patchwork Sat Dec 31 21:58:09 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: 9492797 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 6AAFA62ABB for ; Sat, 31 Dec 2016 22:00:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58EAB1FF35 for ; Sat, 31 Dec 2016 22:00:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A6822094F; Sat, 31 Dec 2016 22:00: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=-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 101F61FF35 for ; Sat, 31 Dec 2016 22:00:35 +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 1cNRfz-0007k5-Ey; Sat, 31 Dec 2016 21:58:55 +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 1cNRfw-0007iG-OJ; Sat, 31 Dec 2016 21:58:53 +0000 Received: from [192.168.1.2] ([77.182.161.10]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0McnaL-1c6BlX45Hl-00Hxr0; Sat, 31 Dec 2016 22:58:23 +0100 Subject: [PATCH 1/6] staging: vchiq_arm: Use kmalloc_array() in dump_phys_mem() To: devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, kbuild test robot , popcornmix@gmail.com, Eric Anholt , Greg Kroah-Hartman , Lee Jones , Stefan Wahren , Stephen Warren , Wei Yongjun References: <5acd65e7-0b5d-0972-5e1a-6e87d71dc1a4@users.sourceforge.net> From: SF Markus Elfring Message-ID: <79db6271-a752-579e-df68-d9c917b9006a@users.sourceforge.net> Date: Sat, 31 Dec 2016 22:58:09 +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: <5acd65e7-0b5d-0972-5e1a-6e87d71dc1a4@users.sourceforge.net> X-Provags-ID: V03:K0:2FcvvpXzhtuzvK0mjUTOMM6VMgckzMkKMqGkhiFtzBpu7mE+Tha +JxePWlWO5ztQeRHJaQ7ZfBu8mmT+6qqnjTWjXjckiQ8bhgJelt8shVvFsLm/vRLL/vCjW7 Wa1qEuvjOi8mJTABcwImNSSJLgMm6Qek4nNVz2CqarMq48Y9GyhqIU3VmEmE3O0NqsDcVaL P1vnn31AbKVmlDgJNme/w== X-UI-Out-Filterresults: notjunk:1; V01:K0:Hqw1HczAqPc=:SqV6zOdCOqmVq+DBcs8xso /dxD+DOi2lufOeQ6cOeLbIyL+s2SjHvpECTx/kmvTKWSMVVUmMX8XfD6MXdPqeGhZQ4IBmJ/1 mVTtoQHg6k5rIk9oNI5/6o9aqsH997D9It74+yqW8FSAuk9RW7Zn9iOB+jUTkYI1qe6Jsy+cS xwT8ZkVeBQsgm2SIUrvzMGZ6iRyilroGJb9TRRjSyP1B04FkGN2zGKrJVCSVtSnEjTlWKmTOG s5HyuHRIufPHbM65DBALQfx7DUdkiDWI6+ZLSuS/AcQ8hTFO1expExNsFTxlkOoAzGQhRB7zK mD9uvihBghKfa0VYWnyna2NomsXK/IkqdRknL5V9aL/dFxILDKjaRK/y146oE//QFGWaSJTeO qz9MV+leXfuH6gJ6G8vUtDbaoGv4JKrAaJ24w+4HZjAXtJENxx3oLFCFviVaCygTkm4sVOgqt hqty8lD7FvNGBjXA45dos0PwdO2uqecKeQy9X2uv2mHXqZl105Qn+LhRnf50hlcXT4kQRiwuL eI5PDrRF45Ng7H5Dj0DAnsBVD9OpnfD6avq7zCURlBDf2hdKeExXxOEDk7YIOAlkKPrRzSRbZ MM01rnsfvbdm8cflfSNX5tkyZlyOuUzdCN1+16IwHZpa+Ex6MwdAIy0NzOA22qaBX388aZsBu VhkBrJWUCZhjDVjhzguQyvUBxzUiESj5AQox6Oor3n/yEO3hgzw4spLaFxty0IsqSeuLbHImH XCn46qOvhXdXb1pJXJAF+DWXE+OARYO6mLwkWas0F9aLO7z5e1ioWaIBy0t4YBM1UDZQvHKt4 XYvHv0h X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161231_135853_170928_55936633 X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. 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: kernel-janitors@vger.kernel.org, LKML 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: Sat, 31 Dec 2016 17:50:25 +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/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 610e0d6d93bb..4af77d790ae0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1558,8 +1558,7 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes) end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1); num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE; - - pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); + pages = kmalloc_array(num_pages, sizeof(*pages), GFP_KERNEL); if (pages == NULL) { vchiq_log_error(vchiq_arm_log_level, "Unable to allocation memory for %d pages\n",