public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/amd_nb: Use kmalloc_array() in amd_cache_gart()
@ 2016-09-04 19:08 SF Markus Elfring
  2016-09-04 19:23 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2016-09-04 19:08 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar, Paul Gortmaker,
	Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 21:01:47 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/kernel/amd_nb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 4fdf623..e2e3e8a 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -226,7 +226,9 @@ static void amd_cache_gart(void)
 	if (!amd_nb_has_feature(AMD_NB_GART))
 		return;
 
-	flush_words = kmalloc(amd_nb_num() * sizeof(u32), GFP_KERNEL);
+	flush_words = kmalloc_array(amd_nb_num(),
+				    sizeof(*flush_words),
+				    GFP_KERNEL);
 	if (!flush_words) {
 		amd_northbridges.flags &= ~AMD_NB_GART;
 		pr_notice("Cannot initialize GART flush words, GART support disabled\n");
-- 
2.9.3

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

end of thread, other threads:[~2016-09-04 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-04 19:08 [PATCH] x86/amd_nb: Use kmalloc_array() in amd_cache_gart() SF Markus Elfring
2016-09-04 19:23 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox