From 8797fe75f164d4b2f183e776003612ece565c76e Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Sep 2016 20:40:57 +0200 Subject: tile-module: Use kmalloc_array() in module_alloc() * 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 Signed-off-by: Chris Metcalf --- arch/tile/kernel/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/tile/kernel/module.c') diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c index 2305084c9b93..dce4120f5263 100644 --- a/arch/tile/kernel/module.c +++ b/arch/tile/kernel/module.c @@ -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) { -- cgit v1.2.3 From 8e36f722f73f2fc1766af1af0b2f56f2299ba687 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Sep 2016 20:45:20 +0200 Subject: tile-module: Rename jump labels in module_alloc() Adjust jump labels according to the current Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Chris Metcalf --- arch/tile/kernel/module.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'arch/tile/kernel/module.c') diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c index dce4120f5263..09233fbe7801 100644 --- a/arch/tile/kernel/module.c +++ b/arch/tile/kernel/module.c @@ -49,23 +49,22 @@ void *module_alloc(unsigned long size) for (; i < npages; ++i) { pages[i] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM); if (!pages[i]) - goto error; + goto free_pages; } area = __get_vm_area(size, VM_ALLOC, MEM_MODULE_START, MEM_MODULE_END); if (!area) - goto error; + goto free_pages; area->nr_pages = npages; area->pages = pages; if (map_vm_area(area, prot_rwx, pages)) { vunmap(area->addr); - goto error; + goto free_pages; } return area->addr; - -error: + free_pages: while (--i >= 0) __free_page(pages[i]); kfree(pages); -- cgit v1.2.3