From: Markus Elfring <[email protected]>
Date: Thu, 1 Sep 2016 14:41:01 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
---
 arch/s390/kernel/debug.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index aa12de7..8e2be30 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -196,14 +196,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
        debug_entry_t*** areas;
        int i,j;
 
-       areas = kmalloc(nr_areas *
-                                       sizeof(debug_entry_t**),
-                                       GFP_KERNEL);
+       areas = kmalloc_array(nr_areas, sizeof(*areas), GFP_KERNEL);
        if (!areas)
                goto fail_malloc_areas;
        for (i = 0; i < nr_areas; i++) {
-               areas[i] = kmalloc(pages_per_area *
-                               sizeof(debug_entry_t*),GFP_KERNEL);
+               areas[i] = kmalloc_array(pages_per_area,
+                                        sizeof(*areas[i]),
+                                        GFP_KERNEL);
                if (!areas[i]) {
                        goto fail_malloc_areas2;
                }
-- 
2.9.3

Reply via email to