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


Groups > linux.kernel > #1482767

[PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init()
Date 2016-09-13 22:50 +0200
Message-ID <sh2Ou-6TO-27@gated-at.bofh.it> (permalink)
References <qEuGl-43C-5@gated-at.bofh.it> <sh2EN-6PW-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 21:30:58 +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>
---
 drivers/char/agp/sgi-agp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 3051c73..798ad20 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -280,9 +280,9 @@ static int agp_sgi_init(void)
 	else
 		return 0;
 
-	sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
-					sizeof(struct agp_bridge_data *),
-					GFP_KERNEL);
+	sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
+					      sizeof(*sgi_tioca_agp_bridges),
+					      GFP_KERNEL);
 	if (!sgi_tioca_agp_bridges)
 		return -ENOMEM;
 
-- 
2.10.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:40 +0200
  [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in  uninorth_create_gatt_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
    Re: [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in  uninorth_create_gatt_table() kbuild test robot <lkp@intel.com> - 2016-09-15 19:40 +0200
      Re: [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in  uninorth_create_gatt_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-15 20:30 +0200
  [PATCH 1/7] AGPGART: Use kmalloc_array() in  compat_agpioc_reserve_wrap() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
  [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
  [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in  uninorth_create_gatt_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
  [PATCH 2/7] AGPGART: Use memdup_user() rather than duplicating its  implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
  [PATCH 3/7] AGPGART: Rename jump labels in compat_agp_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 22:50 +0200
  [PATCH 7/7] AGPGART-UniNorth: Delete an unnecessary check in  uninorth_create_gatt_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-13 23:00 +0200

csiph-web