All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()
@ 2016-09-04 20:23 ` SF Markus Elfring
  0 siblings, 0 replies; 22+ messages in thread
From: SF Markus Elfring @ 2016-09-04 20:23 UTC (permalink / raw)
  To: x86, Dave Young, H. Peter Anvin, Ingo Molnar, Kees Cook,
	Matt Fleming, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 22:15:09 +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 <elfring@users.sourceforge.net>
---
 arch/x86/kernel/ksysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
index 4afc67f..cddf3c6 100644
--- a/arch/x86/kernel/ksysfs.c
+++ b/arch/x86/kernel/ksysfs.c
@@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
 	if (ret)
 		goto out_setup_data_kobj;
 
-	kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL);
+	kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL);
 	if (!kobjp) {
 		ret = -ENOMEM;
 		goto out_setup_data_kobj;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-09-07 17:01 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-04 20:23 [PATCH] x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes() SF Markus Elfring
2016-09-04 20:23 ` SF Markus Elfring
2016-09-06 21:49 ` Kees Cook
2016-09-06 21:49   ` Kees Cook
2016-09-07  7:49   ` SF Markus Elfring
2016-09-07  7:49     ` SF Markus Elfring
2016-09-07 10:36     ` Paolo Bonzini
2016-09-07 10:36       ` Paolo Bonzini
2016-09-07 11:17       ` SF Markus Elfring
2016-09-07 11:17         ` SF Markus Elfring
2016-09-07 11:20         ` Paolo Bonzini
2016-09-07 11:20           ` Paolo Bonzini
2016-09-07 11:45           ` SF Markus Elfring
2016-09-07 11:45             ` SF Markus Elfring
2016-09-07 16:23             ` Kees Cook
2016-09-07 16:23               ` Kees Cook
2016-09-07 16:37               ` Joe Perches
2016-09-07 16:37                 ` Joe Perches
2016-09-07 17:01                 ` Kees Cook
2016-09-07 17:01                   ` Kees Cook
2016-09-07 16:55               ` SF Markus Elfring
2016-09-07 16:55                 ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.