From patchwork Wed Sep 21 07:24:52 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: 9342943 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 28FB56077A for ; Wed, 21 Sep 2016 07:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ECB82A19F for ; Wed, 21 Sep 2016 07:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 016CC2A1A4; Wed, 21 Sep 2016 07:25: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 6E9D62A19F for ; Wed, 21 Sep 2016 07:25:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3563C6E7B7; Wed, 21 Sep 2016 07:25: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 61EBE6E7B7 for ; Wed, 21 Sep 2016 07:25:06 +0000 (UTC) Received: from [192.168.1.2] ([77.182.212.253]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LnS3i-1bKgjw0UD0-00hbtZ; Wed, 21 Sep 2016 09:24:54 +0200 Subject: [PATCH 1/5] GPU-DRM-nouveau: Use kmalloc_array() in nvbios_iccsense_parse() To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Ben Skeggs , David Airlie , Martin Peres , Roy Spliet References: <5bcff2ec-f3bd-ab9c-e13d-3a4f5cf7c73b@users.sourceforge.net> From: SF Markus Elfring Message-ID: <77983748-8b67-5ee1-e94b-5f3b8c221ad0@users.sourceforge.net> Date: Wed, 21 Sep 2016 09:24:52 +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: <5bcff2ec-f3bd-ab9c-e13d-3a4f5cf7c73b@users.sourceforge.net> X-Provags-ID: V03:K0:YSpjeZ3Y1D6xXG9o8b2wTE0w1E7IiTonCgbaZKDXcPx9RXTlXVw ZKN6iDaeQ+3+lLIRmEb4mCrhvQO2xkbtHPZCYlfReFA/MnzErWsjRwtC5kJ/o8jKn2tmAxR vsP5egbkFtO6s2B/3WBCqofcJihXbxpOnjhu5QsWtNuQh/vv/lx245o98ArcjRFuOVwNolG WfyAkvBnLY1jAjn6fmSEg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Ndb1LtuQ/PI=:OWF2YpvXPjySV+gVvvbC8i Nd2cOM/4rTZNSZXLQEVkS7x/ykq7sDy/S4q6lIZZupjyYcKv1LFuXVCE8Y1kDh2mdT7xZ6cuu phGt4ycOzKf9Olr0olRsgEzWP69Hs9v6LYAmg7UccJgaaEv8xYUuMdMcE6riR6+qa3Nl5m4wA scMdqp4PoZUMrZfq+/bz6tTRU5UM6f6x4laofSjpoP23/X20f/aeu1PrythD423KViaGXGDHR Xb/pk2gm5Fq6x1EQXYkxE5raitoqjrACHgRW7/q0ARKe7XO2/KWdEXRV/u3iyccS/94pcj+5e l9hDcyRTFX3TKVChEdxI/bTskyX97ZurrCeRaEIbZwTV9v+gb/+PE6pnRii2HuGQNooiewQ3c 0W3wiHps1JSLhtklzmerloT09ebBjReFT/MXuyH31reI5DH/Si/GFHhE4x/9NmFJhmhjdC34x NJjhYOtmH7TsEsrzlAwzMBWxeU+iRiQalrhbv8+q+5yCsJu0Otv3vH3YL4GTqWxW3yfBWwB8R +hGvgDUtLYEoRXR57aCnBIbo2Oyev6yNblsL0ItCqfvH4f5zvX9dXLnVKc5AbrgIC6Xfr24uj 6OYtYRSw6Yxl0cfffpMIdkAe75k2tucmTgBeMo5L0qhdwfUSJ/YKvdkBBMlDIcboXPwd4ZhqW jqkeAwHQJMePYZwisMAZ73ssQ0oNq1rKK2Wu7Nceb1nCLjWLAhosVWY1rGa2b/waHyKXbz6Ki G6AtaCOmEHGuLJDY1j4zaiiBBvYbD2hWilPrqjuhowpumtS+QL56kbguP1ZxrM2TiwF0luICy 7UolBXF Cc: trivial@kernel.org, kernel-janitors@vger.kernel.org, LKML , Julia Lawall 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: Tue, 20 Sep 2016 22:22:14 +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 structure 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/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c index 0843280..91cf1ee 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c @@ -72,7 +72,9 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense) } iccsense->nr_entry = cnt; - iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL); + iccsense->rail = kmalloc_array(cnt, + sizeof(*iccsense->rail), + GFP_KERNEL); if (!iccsense->rail) return -ENOMEM;