Skip to contentSkip to conversation

x86/hpet: Use kmalloc_array() in hpet_enable()

PATCH New SF Markus Elfring 1 participant 1 message Sep 4, 2016

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

PATCH 1/1 x86/hpet: Use kmalloc_array() in hpet_enable()

From: Markus Elfring <[email protected]>
Date: Sun, 4 Sep 2016 21:30:10 +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.

---
 arch/x86/kernel/hpet.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/hpet.c +3 -2
index c6dfd80..3c2030d 100644
@@ -876,8 +876,9 @@ int __init hpet_enable(void)
 #endif
 
 	cfg = hpet_readl(HPET_CFG);
-	hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
-				GFP_KERNEL);
+	hpet_boot_cfg = kmalloc_array(last + 2,
+				      sizeof(*hpet_boot_cfg),
+				      GFP_KERNEL);
 	if (hpet_boot_cfg)
 		*hpet_boot_cfg = cfg;
 	else
Signature · 1 line
2.9.3