[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <190dbaf0-e4ef-859a-346b-eb5ae5dfe583@users.sourceforge.net>
Date: Mon, 5 Sep 2016 10:10:09 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: x86@...nel.org, Andi Kleen <ak@...ux.intel.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Borislav Petkov <bp@...e.de>, "H. Peter Anvin" <hpa@...or.com>,
Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
Jürgen Groß <jgross@...e.com>,
Len Brown <len.brown@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org,
Julia Lawall <julia.lawall@...6.fr>,
Paolo Bonzini <pbonzini@...hat.com>
Subject: [PATCH 1/4] x86/smpboot: Use kmalloc_array() in
smp_init_package_map()
From: Markus Elfring <elfring@...rs.sourceforge.net>
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 <elfring@...rs.sourceforge.net>
---
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);
size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
physical_package_map = kzalloc(size, GFP_KERNEL);
--
2.9.3
Powered by blists - more mailing lists