From: Markus Elfring <[email protected]>
Date: Tue, 13 Sep 2016 21:50:44 +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 <[email protected]>
---
 drivers/char/agp/uninorth-agp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index fdced54..8d144cd 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct 
agp_bridge_data *bridge)
        if (table == NULL)
                return -ENOMEM;
 
-       uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct 
page*), GFP_KERNEL);
+       uninorth_priv.pages_arr = kmalloc_array(1 << page_order,
+                                               
sizeof(*uninorth_priv.pages_arr),
+                                               GFP_KERNEL);
        if (uninorth_priv.pages_arr == NULL)
                goto enomem;
 
-- 
2.10.0

Reply via email to