Skip to contentSkip to conversation

PA-RISC-inventory: Use kmalloc_array() in add_system_map_addresses()

PATCH New SF Markus Elfring 1 participant 1 message Aug 28, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PA-RISC-inventory: Use kmalloc_array() in add_system_map_addresses()

From: Markus Elfring <[email protected]>
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.

---
 arch/parisc/kernel/inventory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/inventory.c +1 -1
index f0b6722..545f9d2 100644
@@ -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__);
Signature · 1 line
2.9.3