Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1469855 > unrolled thread

[PATCH] [IA64] MCA: Use kmalloc_array() in init_record_index_pools()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-08-25 08:00 +0200
Last post2016-08-25 08:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] [IA64] MCA: Use kmalloc_array() in init_record_index_pools() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-25 08:00 +0200

#1469855 — [PATCH] [IA64] MCA: Use kmalloc_array() in init_record_index_pools()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-08-25 08:00 +0200
Subject[PATCH] [IA64] MCA: Use kmalloc_array() in init_record_index_pools()
Message-ID<s9VRL-5gY-9@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Aug 2016 07:37:46 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure 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/ia64/kernel/mca_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index 94f8bf7..e4ce128 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -349,9 +349,9 @@ init_record_index_pools(void)
 
 	/* - 3 - */
 	slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
-	slidx_pool.buffer =
-		kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
-
+	slidx_pool.buffer = kmalloc_array(slidx_pool.max_idx,
+					  sizeof(*slidx_pool.buffer),
+					  GFP_KERNEL);
 	return slidx_pool.buffer ? 0 : -ENOMEM;
 }
 
-- 
2.9.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web