tile-module: Use kmalloc_array() in module_alloc()
authorMarkus Elfring <[email protected]>
Sat, 3 Sep 2016 18:40:57 +0000 (20:40 +0200)
committerChris Metcalf <[email protected]>
Fri, 16 Dec 2016 20:32:29 +0000 (15:32 -0500)
* 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".

* 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]>
Signed-off-by: Chris Metcalf <[email protected]>
arch/tile/kernel/module.c

index 2305084c9b93b72df9f5fba6f6302037d0fb43a7..dce4120f52630a7ad7d19b3b120e1ad2534a42a5 100644 (file)
@@ -43,7 +43,7 @@ void *module_alloc(unsigned long size)
        int npages;
 
        npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
-       pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL);
+       pages = kmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
        if (pages == NULL)
                return NULL;
        for (; i < npages; ++i) {