From patchwork Mon Sep 19 15:53:49 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: 9339797 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 832A36077A for ; Mon, 19 Sep 2016 15:54:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74534294A2 for ; Mon, 19 Sep 2016 15:54:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68FB929569; Mon, 19 Sep 2016 15:54:06 +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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 894D22953A for ; Mon, 19 Sep 2016 15:54:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BA246E4BE; Mon, 19 Sep 2016 15:53:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [212.227.15.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DC206E4BE for ; Mon, 19 Sep 2016 15:53:56 +0000 (UTC) Received: from [192.168.1.2] ([77.182.197.179]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0Lvf5Q-1auN502HW8-017S8a; Mon, 19 Sep 2016 17:53:50 +0200 Subject: [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie References: <566ABCD9.1060404@users.sourceforge.net> <2fd2da19-d57e-5017-0594-fd52e78493fa@users.sourceforge.net> From: SF Markus Elfring Message-ID: Date: Mon, 19 Sep 2016 17:53:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <2fd2da19-d57e-5017-0594-fd52e78493fa@users.sourceforge.net> X-Provags-ID: V03:K0:6L5yZXfoeEhxwrdBTPXFRhjU1l/OULRUe6OQw6iSa9T0neyg0+I DaR4HUtrL0i3Vnt/ucDjXakVQwu6hHT7r+FCKer/YO7STkHtZ59Q9cYBfMKsQnw27/bTQMM g04oiIl8YEBeLiuFrjVtgyIvbh1WEdCGXtmvXWf1Txyt6etLms4WxhqpesllJNZveKIbB6u t3z/cNJOF9S9cl5+9JQhg== X-UI-Out-Filterresults: notjunk:1; V01:K0:ApVTL/idtkQ=:Jrio7hFZ08X7blDQw11+cc plfvbl+SAT1bn+OAFA2dfQ82ra+vYyiaR7on/VPcs4lvV21HtCCLEz3Vb1UsR9cQJx1bkd8dJ eRc5oFwHvUclM/FjHSHWwschsnRw7lHTODRxCMOFwlJoLATYy7OkY3zaJ/U7Kg2g73e5/eJEx zOc7FM1RzD3tOEGnRtOcpqjqdKTVYiIZB9uaR9MTgfTzt/bvNXPi5SPybO5t2UyFEo/yQoz0+ fdE6MwBNcMQHNztaWirkGxxGc8+cpZnlo8u/IjlSJHgptJDii5OB51O1/Y5T2GWjqTEkIf3f0 jhtjVkwIwal8kTDnRPvRN9iYBbJQyYAFnSHPTr6aDEZc0oZ9yP6c3WKioHx2aBzLb9eXYXNc6 gghdhyRZ7khLkldAzOTunRmJN6rz3MCqJSaIqGiv8kW8pxBGDXgmCrg62o7WNJmtN6/wzMPdH 9ZAYRDAbEqZXQIWW14Yny+7r5nqS79Sa23LgRhsYuOI36bxICiNQCSU46d+xX1HIB6OK2A6DJ FEoH1rH1b/rEf3gvPZS9fgrj7R+oXe60zCkRsd8F4jRg2I+mMlUWzFSnXLubOAoPoIiwKKmzo T6k0jRWNv1h4Ih9LHngfLhJ16Qb6UP3ksX8wznbsfWLE4WoJmTD6fDlUjU4bAbIYtMC321HyV qh9m4NdDMSsjDTxYgjFk9xGYW6aCIuPbQbV8j3MaTIJGnIDdcefNGslhDkn8a2w1ScFRyKMq3 h8/1zqSpk2QbSjwXbrKdsPpXJ/voX90mGSutgJx6dHmNRYzGGP67FIfpGKICeli+ath5nzNqf J06lgh0 Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 19 Sep 2016 17:07:06 +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. Signed-off-by: Markus Elfring --- drivers/gpu/drm/drm_bufs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 3219151..ed33f43 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev, /* Keep the original pagelist until we know all the allocations * have succeeded */ - temp_pagelist = kmalloc((dma->page_count + (count << page_order)) * - sizeof(*dma->pagelist), GFP_KERNEL); + temp_pagelist = kmalloc_array(dma->page_count + (count << page_order), + sizeof(*dma->pagelist), + GFP_KERNEL); if (!temp_pagelist) { kfree(entry->buflist); kfree(entry->seglist);