From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755515AbcIEJXL (ORCPT ); Mon, 5 Sep 2016 05:23:11 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:58830 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbcIEJXE (ORCPT ); Mon, 5 Sep 2016 05:23:04 -0400 Date: Mon, 5 Sep 2016 11:19:51 +0200 (CEST) From: Thomas Gleixner To: SF Markus Elfring cc: x86@kernel.org, Andi Kleen , Boris Ostrovsky , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Jiri Olsa , =?ISO-8859-15?Q?J=FCrgen_Gro=DF?= , Len Brown , Peter Zijlstra , LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini Subject: Re: [PATCH 1/4] x86/smpboot: Use kmalloc_array() in smp_init_package_map() In-Reply-To: <190dbaf0-e4ef-859a-346b-eb5ae5dfe583@users.sourceforge.net> Message-ID: References: <6dacb257-d15c-8ea1-9dd4-0440a5ecfd1d@users.sourceforge.net> <190dbaf0-e4ef-859a-346b-eb5ae5dfe583@users.sourceforge.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Sep 2016, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 5 Sep 2016 08:30: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 type by a pointer dereference > to make the corresponding size determination a bit safer according to > the Linux coding style convention. > > * Move a calculation for one function call. > > Signed-off-by: Markus Elfring > --- > arch/x86/kernel/smpboot.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index 3878725..36cf27e 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -349,9 +349,12 @@ static void __init smp_init_package_map(void) > * package can be smaller than the actual used apic ids. > */ > max_physical_pkg_id = DIV_ROUND_UP(MAX_LOCAL_APIC, ncpus); > - size = max_physical_pkg_id * sizeof(unsigned int); > - physical_to_logical_pkg = kmalloc(size, GFP_KERNEL); > - memset(physical_to_logical_pkg, 0xff, size); > + physical_to_logical_pkg = kmalloc_array(max_physical_pkg_id, > + sizeof(*physical_to_logical_pkg), > + GFP_KERNEL); > + memset(physical_to_logical_pkg, > + 0xff, > + sizeof(*physical_to_logical_pkg) * max_physical_pkg_id); Why are you replacing well readable code by this line breaked crap? Stop acting like a shell script or we might replace you by one. Thanks, tglx