Skip to contentSkip to conversation

powerpc: Use kmalloc_array() in grow()

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

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

PATCH 1/1 powerpc: Use kmalloc_array() in grow()

From: Markus Elfring <[email protected]>
Date: Mon, 29 Aug 2016 07:50:33 +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/powerpc/lib/rheap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/rheap.c +1 -1
index 94058c2..1630764 100644
@@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks)
 
 	new_blocks = max_blocks - info->max_blocks;
 
-	block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC);
+	block = kmalloc_array(max_blocks, sizeof(*block), GFP_ATOMIC);
 	if (block = NULL)
 		return -ENOMEM;
 
Signature · 1 line
2.9.3