From patchwork Sun Sep 18 16:50:08 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: 9337961 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 B43DA6077F for ; Sun, 18 Sep 2016 16:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94BBF28993 for ; Sun, 18 Sep 2016 16:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74A6B28C63; Sun, 18 Sep 2016 16:50:40 +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 13E3428993 for ; Sun, 18 Sep 2016 16:50:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 574A76E0F5; Sun, 18 Sep 2016 16:50:32 +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 [217.72.192.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21C7C6E0F5 for ; Sun, 18 Sep 2016 16:50:28 +0000 (UTC) Received: from [192.168.1.2] ([77.181.85.138]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0Le4Tw-1bDU921aTk-00pwZk; Sun, 18 Sep 2016 18:50:20 +0200 Subject: [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() To: dri-devel@lists.freedesktop.org, Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , Chunming Zhou , David Airlie , Monk Liu , Tom St Denis References: <566ABCD9.1060404@users.sourceforge.net> <8d614254-1cba-0379-cf84-52ad9bd9f3a7@users.sourceforge.net> From: SF Markus Elfring Message-ID: <976bba66-8e9b-d5ee-a266-d291986e63d7@users.sourceforge.net> Date: Sun, 18 Sep 2016 18:50:08 +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: <8d614254-1cba-0379-cf84-52ad9bd9f3a7@users.sourceforge.net> X-Provags-ID: V03:K0:NF+HUN9sIHi01OCx3h8Hwv+U9vszUyFJMrwURy7vgsqkruhgVvf LQHieU89bJxTmXLoU1oC7kKdK3y6m0qlguDviE9H1vlOAJv/O+HJtZMRtCdt0GEzLBxcXMk Q+6+7PefAbSszE99HoHPkhR1hqJP/vKjEEvv5zKWHagSw9pd75t7ZiIytqNzgUIuFEyJXtP nHudLi5UNHAtE5Df0fX5g== X-UI-Out-Filterresults: notjunk:1; V01:K0:CwQbVw91P6w=:/GrkoLtZMxGQsNm2P7uPon rnqE7CSTatofe0ObpNgE7i0a5I0Ujfh3NxgadzJ3jVwD5ZAEorHCIaaSwgF9jbPFqTRo+teuQ odWcicaiIsaD9/gF2Rv2lqb9pCvO+XiV2fI8Iuv2qmsaIg7iErhv3UMkUqeu7ZteXn9krGSYN oyWRYwhGYY+RWDo2b1wHMusPYMaWxKrM+OD+CmOxxmrdyBNCHPLZIjYMFeyzLDx+QUZF3L8Jc NcUTzU8hYADzeUoBuoPBs/li85RaDxLyzC14RvMTRIM0dzlAxbDrnRE2+u9CubIVmKhm/MyUs janC7jOooygdJi1u4GTN1Un3Alcr7AhvZYtQurIap/aKaKuvqaCzSPozXCgOTamANue7n8KNF ZoS96WlL3KDC/tYMabQSMLkLdqu7NlxXTGswy0Hd3zvGjm05my0jrL1PUKRZE1P3RrdNoeLL0 /cYzGqIXZDFCrOmzU9Nl4jNbcmO3JX/WaEhahLIWW2sUH4Wj0HmMWUztZcSS1oVYv7ndIbQoZ HVV3c5xLzZuPzJM7E3Tgw58d+2g/F9UfwlbWBQ8MT6GTdxvcJhmqSMngrOwkCvOzN//95REnM PD7kJF7xjZgyy/oYj3+W8V2eM+AOxQtxjdSkfMvJp2yjJ8Hxx3DqLQf5EUHLJ58U28HOdKkfb cQ9vcIegPAw7S0eTtuJSLtJQr7xFiGGkZM6m03UWqIMVvBO2pNk+PchJ/mHeWy+vyWcIBuFM3 MLwV9H3mQR+aVUYiPc6nEmQANyk3m41HM5tG/NuIlK85b3UhUA0w+7/EuM7ouVRKrruR/tp5Q yOg2G3z 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: Sun, 18 Sep 2016 17:00:52 +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/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index df7ab245..2709ebd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2438,7 +2438,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf, if (size & 0x3 || *pos & 0x3) return -EINVAL; - config = kmalloc(256 * sizeof(*config), GFP_KERNEL); + config = kmalloc_array(256, sizeof(*config), GFP_KERNEL); if (!config) return -ENOMEM;