From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbcIDJCy (ORCPT ); Sun, 4 Sep 2016 05:02:54 -0400 Received: from mout.web.de ([212.227.17.12]:54839 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbcIDJCt (ORCPT ); Sun, 4 Sep 2016 05:02:49 -0400 To: x86@kernel.org, Alexander Shishkin , Arnaldo Carvalho de Melo , "H. Peter Anvin" , Ingo Molnar , Peter Zijlstra , Thomas Gleixner Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Subject: [PATCH] perf/x86: Use kmalloc_array() in merge_attr() Message-ID: Date: Sun, 4 Sep 2016 11:00:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:v/oOeKN8PLWA/Heu+b0yHOT/+SOT9O/+njVwt8lnGvZ2yAPWpBJ 5IHKB5n583a6W9qYp+xa2EfLOvlNcPftE6UcW8WJLWvqMhqZ/kQnIYdwu8KsztXNbl5E8TU cXaNLaxWOv5V6Zrj//8ThPeL1b+cyWiX3QOMQdNyJvWMQUQt3WNfBWCEHBEIRy7DOaD7p5t 3/ZnWqrWtK4iKfKPPZOmw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Qeprhc5ntlo=:ZRnQIt5bVjss+Us+X3Pbkz Kn3xbRbKztCDXHE/JwXP5npqghPzMOcrG5Sr+i3pRoTR1xzp2XcI+9LNDBU+oK4CElIwD2Fbd 2AJwCAgoPWywXg9xo2f6mF3byvZc9ycbL6me2G4yPEcHCNEAMP1ivmHQfvbI1XMbePwEUgHvX Bwbw6YOV8oCECx4BhIVHr5YAj3I0YCOWefDMHTfADVTKJI2U6hWx26QG/kepMsxLvOMeQOuxX oxHrNQ/HbFw7oUR6xW8BUc3h+aGBb1QWRraP7DtCH9ZbAzAF4ry5Idbo6ulry5N97jWK0ffNE mXpJgtlCPPcCijOSVXfjZ1HnFJAOcX6CcvFMMc1alyZ7AihEXXHnzfPch7NRygYjvrMKEJ5QS hsP9oxqsjp9ZPBk+2WdOHSPPSaKwvrj6PN0QMpOJBpcHrhMNsN5phJfm6CPTs5XHVwz+1Z2w6 MYTJ0zP+DKuwfL6TEbCNDwszE74sdFJYJmmv1XPXbnzbEUsEdfOkBes5lhQrxevZmwr4QW+v7 DngXyJBAguo1iwjIB5q9G2i6h/qk6FklxgPrETTVwZsTHwovQRwiMEpxmF6s4adypwOcfiPN+ KGbW5hKDdWM4lqrwzj6N0M7hIglMiAZocdu4+SzZ2UVHZwGK6mGCeZ3bTGRPOR7u18C9gdgo4 LR0R7n6/FBghA9nMXCq5C3RRZ9pKM9yQ2ws5Cj8uT1qOAr3uauXsmx5crfWXIXwf4SETkzAtZ k/bzrtcGXMXPniubORai7MAZ4IELXjTGwa59vWLgbzAgE9KSwf1qGghw7s/4vW3Ryi2J8KGrh sE4AtK0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 4 Sep 2016 10:45:20 +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 --- arch/x86/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 18a1acf..f7f3578 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1618,7 +1618,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b) j++; j++; - new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL); + new = kmalloc_array(j, sizeof(*new), GFP_KERNEL); if (!new) return NULL; -- 2.9.3