* [PATCH] PA-RISC-inventory: Use kmalloc_array() in add_system_map_addresses()
@ 2016-08-28 9:50 SF Markus Elfring
0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2016-08-28 9:50 UTC (permalink / raw)
To: linux-parisc, Helge Deller, James E. J. Bottomley
Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 11:40:53 +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 <elfring@users.sourceforge.net>
---
arch/parisc/kernel/inventory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c
index f0b6722..545f9d2 100644
--- a/arch/parisc/kernel/inventory.c
+++ b/arch/parisc/kernel/inventory.c
@@ -506,7 +506,7 @@ add_system_map_addresses(struct parisc_device *dev, int num_addrs,
long status;
struct pdc_system_map_addr_info addr_result;
- dev->addr = kmalloc(num_addrs * sizeof(unsigned long), GFP_KERNEL);
+ dev->addr = kmalloc_array(num_addrs, sizeof(*dev->addr), GFP_KERNEL);
if(!dev->addr) {
printk(KERN_ERR "%s %s(): memory allocation failure\n",
__FILE__, __func__);
--
2.9.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-28 9:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-28 9:50 [PATCH] PA-RISC-inventory: Use kmalloc_array() in add_system_map_addresses() SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome