From patchwork Fri Sep 23 16:36:48 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: 9348457 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 64EEA6077A for ; Fri, 23 Sep 2016 16:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5515C2ABBC for ; Fri, 23 Sep 2016 16:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46F782AC6F; Fri, 23 Sep 2016 16:37:12 +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 312502ABBC for ; Fri, 23 Sep 2016 16:37:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3DBC16EAE9; Fri, 23 Sep 2016 16:37:10 +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.4]) by gabe.freedesktop.org (Postfix) with ESMTPS id C18246EAE9 for ; Fri, 23 Sep 2016 16:37:08 +0000 (UTC) Received: from [192.168.1.2] ([77.182.222.137]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MeSYJ-1bbYix1V3n-00Q7nI; Fri, 23 Sep 2016 18:37:00 +0200 Subject: [PATCH 1/3] drm/vmwgfx: Use kmalloc_array() in vmw_surface_define_ioctl() To: dri-devel@lists.freedesktop.org, linux-graphics-maintainer@vmware.com, David Airlie , Sinclair Yeh , Thomas Hellstrom References: <8de6f7c3-5614-b210-7b2f-66c1aed4279b@users.sourceforge.net> From: SF Markus Elfring Message-ID: Date: Fri, 23 Sep 2016 18:36:48 +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: <8de6f7c3-5614-b210-7b2f-66c1aed4279b@users.sourceforge.net> X-Provags-ID: V03:K0:NHlYJIH2kQKmOrY6i/0lPxr32a467bKm8KPZKQRr+ZOmPunXqBK h85lDdSB2ePyG3rbALSOIG7MGJtKtC4aMb3Lr4JQ+Vug1+9qYZRX1wxD1AGOijFJUpURTGv P9sNVpuyCiPFtlCzORk3iUlHGSS5OC9seXPOOYA6y2YsQwj+/VqMtZ968n6BDkxElQYRaF4 eDQA3WhTOoQa8RjIl75xQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:HPYW8EOVo7s=:LX1kzpTk4eEq/PZ+Wz/rua YVfIPEr9NhluDbAnSGr10PyFRf9W2ach3gxEUhVKmG3R1z/848666cPUm/JE+TUEDX+UAH64u knJo58270Oyryly1SgBfy8CM4ColiTIXIlALvXkMjROyJ04LYyeKLcgl9yYQLRkw1tdJOa1bb fr8XSqkIV66x9iDNPpeWvdBL8Wzk8P56mBhAVvLiy1kcBMVoBcY0lW1d3L5tdjdhq1Gotf7te Ov653c8cTs0ud/4m1jG9mRITFMQXEQcY7yoKyzmbaEEhkhpx0hlDtdY+iXdj9q5Uoz8Gat0Bn phHxO14igddAZ6EdfZkNOdVuT9lK2S8650w6EOJJm1Cd0vL1Zilz5pIZoTFMzfy5b1X1wniDq GgBUIsSHQFTD3FAjR39yKSeGeYHhcZ9xxn18gAB4n4aQjOkNNIUcwAJYo7cKCVqPC/9TQw2nw 3acJ+PIOOUWbvXBYJpOPMVfazHWATqonzBKEHbGZtZohqZh6/FzBAdlfGhCDJiUsouDDZe3it dcdXFoClt1kyZ7/B841FjuzY6qiwAe3CuEIJGd2+5LJ2OUuJ0UKMBeIN+Umr/w8OOjaMcz6E+ O3H5kKqyERjxzUyoa9u5Vm9RICTt2+8H8xA9yfPkTzCEyyiFeUdbPWDO4TtLm22PZ9bhAjHQx +YMChyFKJLQqT5mZ0E4SBgBTcAYpfb2c7rxANL+tlpxTVD3xXFdsKLS13SYvAJbJ9xQJClujg F+Eh0spypuo02iuIl74BpW37NJgiB7dYY+03OC9xi5XjPJrxWwSjtlxQ6VxoOQeFFXELXCvTm PpB/E+e 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: Thu, 22 Sep 2016 21:54:33 +0200 Multiplications for the size determination of memory allocations indicated that array data structures 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/vmwgfx/vmwgfx_surface.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index c2a721a..f557549 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -763,14 +763,16 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels)); srf->num_sizes = num_sizes; user_srf->size = size; - - srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL); + srf->sizes = kmalloc_array(srf->num_sizes, + sizeof(*srf->sizes), + GFP_KERNEL); if (unlikely(srf->sizes == NULL)) { ret = -ENOMEM; goto out_no_sizes; } - srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets), - GFP_KERNEL); + srf->offsets = kmalloc_array(srf->num_sizes, + sizeof(*srf->offsets), + GFP_KERNEL); if (unlikely(srf->offsets == NULL)) { ret = -ENOMEM; goto out_no_offsets;