Subject: [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init()

From: SF Markus Elfring <[email-masked]>
Date: Mon, 29 Aug 2016 13:07:37 +0200

From: Markus Elfring <[email-masked]>
Date: Mon, 29 Aug 2016 11:00:11 +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.

Signed-off-by: Markus Elfring <[email-masked]>
---
 arch/powerpc/sysdev/mpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 7de45b2..5e79c0d24 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1641,8 +1641,9 @@ void __init mpic_init(struct mpic *mpic)
 
 #ifdef CONFIG_PM
 	/* allocate memory to save mpic state */
-	mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
-				  GFP_KERNEL);
+	mpic->save_data = kmalloc_array(mpic->num_sources,
+					sizeof(*mpic->save_data),
+					GFP_KERNEL);
 	BUG_ON(mpic->save_data == NULL);
 #endif
 
-- 
2.9.3