From patchwork Tue Feb 7 19:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9560979 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 96C8360236 for ; Tue, 7 Feb 2017 19:49:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89AB025404 for ; Tue, 7 Feb 2017 19:49:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E86028446; Tue, 7 Feb 2017 19:49:10 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35AC825404 for ; Tue, 7 Feb 2017 19:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755478AbdBGTtI (ORCPT ); Tue, 7 Feb 2017 14:49:08 -0500 Received: from mout.web.de ([212.227.17.11]:59172 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932294AbdBGTtG (ORCPT ); Tue, 7 Feb 2017 14:49:06 -0500 Received: from [192.168.1.2] ([78.49.4.3]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MhDYL-1cokKV0v5t-00MJHA; Tue, 07 Feb 2017 20:42:06 +0100 Subject: [PATCH 03/18] HID: Use kmalloc_array() in open_collection() To: linux-input@vger.kernel.org, Benjamin Tissoires , =?UTF-8?Q?Bruno_Pr=c3=a9mont?= , Jiri Kosina References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <2db59cee-8bb5-9b53-993b-c03fe5c58225@users.sourceforge.net> Date: Tue, 7 Feb 2017 20:42:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:3lyy+hso+/tUq/JfULDFlKmcMg6alBpCYpc6osI1s2F1pNMQCzM GeVZduGK+Hj+yZMmWl+MWLhz9jLKFJ25rBsuM+RGvJmwDK7rYkqEiSoEe/YEF+B2EhsV8r8 JaR+4yFvCzYoylu5AgTouv00+5AXYj0d8WWoCbpXKIrIxi6hg1eF4HzUXVJWsoIV2hNwUnW YkkcNXKWVl82l6X7/ZETw== X-UI-Out-Filterresults: notjunk:1; V01:K0:iAKgaJbZG+g=:rmSeAcvqYi03VT+dWaEuF2 ct6shsaMwouQBRFopIAwqtktF+M6iz05H7K94tHXCKLuiQOMUe9kzOhzkWyf7xgbxqBKLPJxK imyvZr/w68oqT0Z8ggi/9zTPQPJFgmDtF1VDdBkISDdLfIcHnZkMRsn+hkJdCvW9jF2dbr9UC PLXkl0PdqaDSPALB4eG35OSnbMahDcrie18vLb+lE/+s3HQuKrI03wZ9OK4Cz7AoRp0vYJYZU D0sLh6h+ELsVjpWFS4j29jxS495J5CwcHrczjRaZLUNegFE36qbB+Z8z/KtGqVLKW/f+o+3HJ suW2OTa0jU++VtNE3Ox5w7aKTujuJy2wR2DkoxJcjidAe9SkJUVbUgVWU2iWeXnFHef0mXC7S MssdyFVKuiI8aYuw3iJKwP3M/PNzKkUalIhhw6aU+6gnahUhKL+8iF2NNW0WEZz0Ls2jW++pV ZaZNpqqMCYADT18LI2vUNyKE9cmJfkRvDACwAr+eilM0Kk7RVFfP2iX4ORgkM5o1UNhsW9Zzn TtCJvR6tU0xoX0EvfORKcuj4PoLfpRhk500U5MFhAHsrQvTMsR0PoCuwsDIM7hIsv38jvGDAy GVAJ/XK0D0aLRbOVMD/aMFkbGST0c1BSMJuD/YEY47eyN6dohvVfXoNuYKarxArJHv4ld2+GH g7Np18OK61eLac0SKpMFxn9IEsHpmJnq+pukdn20wYsN1rEfKiwvklwUp5eDLILYsUSvf7U9G 5rTh/fp/vErdiG/64lULMihoWXaWP0ZBe36Pv5FRa/vDiES6cP3RV68X+TtyWW1H9i4gCkZhr 6S8EaBb Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 6 Feb 2017 19:09:42 +0100 * 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". * 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/hid/hid-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index ffb7e5d4ee19..51f3547ca44f 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -131,8 +131,9 @@ static int open_collection(struct hid_parser *parser, unsigned type) } if (parser->device->maxcollection == parser->device->collection_size) { - collection = kmalloc(sizeof(struct hid_collection) * - parser->device->collection_size * 2, GFP_KERNEL); + collection = kmalloc_array(parser->device->collection_size * 2, + sizeof(*collection), + GFP_KERNEL); if (!collection) return -ENOMEM;