From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757152AbcIMUru (ORCPT ); Tue, 13 Sep 2016 16:47:50 -0400 Received: from mout.web.de ([212.227.15.3]:53513 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbcIMUrs (ORCPT ); Tue, 13 Sep 2016 16:47:48 -0400 Subject: [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in uninorth_create_gatt_table() To: kernel-janitors@vger.kernel.org, David Airlie References: <566ABCD9.1060404@users.sourceforge.net> <5204ca92-2cdf-8115-567c-4ac29816fcec@users.sourceforge.net> Cc: LKML , Julia Lawall From: SF Markus Elfring Message-ID: Date: Tue, 13 Sep 2016 22:47:33 +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: <5204ca92-2cdf-8115-567c-4ac29816fcec@users.sourceforge.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:XcNPdm+XcRpf1uPWqc0XQnGToyr/b0qQHcqSPFq+3pznXfLG8qh lgH4e5HZ6lS+7/OZU9fo1DpEBYOp0CD/y/0JHnsL0LuyHpMdgiQ0tlFiAeIdKP+OEpNhwCj LM6FR2wboJXTCjaICNvCGZmGx1OKdL8bv06aDUumsyPv5S5Ug1EMDfl2XcBChjidfVhs+yT WgophwOasndcXZgpPuIuA== X-UI-Out-Filterresults: notjunk:1;V01:K0:0ehfYsJsJ30=:sUqEDnvw9tQ2l2R1Wtnadd z8FwU1CgsQNXBNh4PFozzpyGZOcoQkBoQzenQj/C9F9lvcYPa8oJGMJOJkjhPCOd1wCOXLvJD l1oD8jC5NpIFm+dz8wbaqb1xt05W0loqg0TlFh1PCBTEh8CAPHvB5JymCaabAtZD4yp6Z1pyp 8qC7QfRdlAzGe/4pemI/fEUPDyBHrxf0wXGjReXXwRBBph9u4+TkRf9KQXtBU8fbDRYWyDyON wPf+YiKqCgFNfTPg/6AZn3AQANTs+cdMiaI82Eal0hvmG1rexDJf+JLiC99acou+8R+FDDcq/ F9pRaJCMe4ZCJ7h42zQtTJLGWbFjxo4ksp6KhEPNVkJRvpyiMeY6mtNGG2p9sHbPm6UN/pces i/IFWyYElgUxtgQxz4aSf60omKthly7prqu34EuSDuFkdlNHYqOMqc5fkiobcuYquWo9QoIrX Yh9l8+KnLh3shP/vcDGk1l5biSstMDioT4VKYZtBANskLBvbALZn31UKg9pPjD+b0Gtv9zBOF sopO3EMUudBLdPis5MNxUkQ9FexeIPwMC7ubM28NQ5qxSID/YZkXDgYy9xNb35Eh2RV9xWDF7 tudMYBp2W2xbPSlxSBr1AWPOEj/04SnkWO/K3CSzZHYIK333pLVfDKK07XGmml77UkEObVL/6 l6VjSvNvljoy4rglowED/B8OqjnoZlFHOQ+Q7jM85MGhRA73Z+G9OfZW9CwJhIl5wjEPaE2oG W2tSlwKva4WYv/GaCnt/TiU4/rNJCg31Zflo8hUx2EqVQ9cdYqTSwPh7s1wgFdZlqklEIXCV+ hdyccQ4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 13 Sep 2016 21:50:44 +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 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/char/agp/uninorth-agp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index fdced54..8d144cd 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c @@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge) if (table == NULL) return -ENOMEM; - uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL); + uninorth_priv.pages_arr = kmalloc_array(1 << page_order, + sizeof(*uninorth_priv.pages_arr), + GFP_KERNEL); if (uninorth_priv.pages_arr == NULL) goto enomem; -- 2.10.0