aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/cris/kernel/module.c2
-rw-r--r--arch/parisc/kernel/module.c2
-rw-r--r--arch/sparc/kernel/module.c4
-rw-r--r--arch/tile/kernel/module.c2
-rw-r--r--arch/unicore32/kernel/module.c3
-rw-r--r--kernel/module.c33
6 files changed, 18 insertions, 28 deletions
diff --git a/arch/cris/kernel/module.c b/arch/cris/kernel/module.c
index 37400f5869e6..51123f985eb5 100644
--- a/arch/cris/kernel/module.c
+++ b/arch/cris/kernel/module.c
@@ -32,8 +32,6 @@
32#ifdef CONFIG_ETRAX_KMALLOCED_MODULES 32#ifdef CONFIG_ETRAX_KMALLOCED_MODULES
33void *module_alloc(unsigned long size) 33void *module_alloc(unsigned long size)
34{ 34{
35 if (size == 0)
36 return NULL;
37 return kmalloc(size, GFP_KERNEL); 35 return kmalloc(size, GFP_KERNEL);
38} 36}
39 37
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index 5e34ccf39a49..2a625fb063e1 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -214,8 +214,6 @@ static inline int reassemble_22(int as22)
214 214
215void *module_alloc(unsigned long size) 215void *module_alloc(unsigned long size)
216{ 216{
217 if (size == 0)
218 return NULL;
219 /* using RWX means less protection for modules, but it's 217 /* using RWX means less protection for modules, but it's
220 * easier than trying to map the text, data, init_text and 218 * easier than trying to map the text, data, init_text and
221 * init_data correctly */ 219 * init_data correctly */
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index f1ddc0d23679..4435488ebe25 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -43,10 +43,6 @@ void *module_alloc(unsigned long size)
43{ 43{
44 void *ret; 44 void *ret;
45 45
46 /* We handle the zero case fine, unlike vmalloc */
47 if (size == 0)
48 return NULL;
49
50 ret = module_map(size); 46 ret = module_map(size);
51 if (ret) 47 if (ret)
52 memset(ret, 0, size); 48 memset(ret, 0, size);
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index 243ffebe38d6..4918d91bc3a6 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -42,8 +42,6 @@ void *module_alloc(unsigned long size)
42 int i = 0; 42 int i = 0;
43 int npages; 43 int npages;
44 44
45 if (size == 0)
46 return NULL;
47 npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; 45 npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
48 pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL); 46 pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL);
49 if (pages == NULL) 47 if (pages == NULL)
diff --git a/arch/unicore32/kernel/module.c b/arch/unicore32/kernel/module.c
index 8fbe8577f5e6..16bd1495b934 100644
--- a/arch/unicore32/kernel/module.c
+++ b/arch/unicore32/kernel/module.c
@@ -27,9 +27,6 @@ void *module_alloc(unsigned long size)
27 struct vm_struct *area; 27 struct vm_struct *area;
28 28
29 size = PAGE_ALIGN(size); 29 size = PAGE_ALIGN(size);
30 if (!size)
31 return NULL;
32
33 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END); 30 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
34 if (!area) 31 if (!area)
35 return NULL; 32 return NULL;
diff --git a/kernel/module.c b/kernel/module.c
index 79a526dd1b11..4542ff3f7ef9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2377,7 +2377,7 @@ static void dynamic_debug_remove(struct _ddebug *debug)
2377 2377
2378void * __weak module_alloc(unsigned long size) 2378void * __weak module_alloc(unsigned long size)
2379{ 2379{
2380 return size == 0 ? NULL : vmalloc_exec(size); 2380 return vmalloc_exec(size);
2381} 2381}
2382 2382
2383static void *module_alloc_update_bounds(unsigned long size) 2383static void *module_alloc_update_bounds(unsigned long size)
@@ -2793,20 +2793,23 @@ static int move_module(struct module *mod, struct load_info *info)
2793 memset(ptr, 0, mod->core_size); 2793 memset(ptr, 0, mod->core_size);
2794 mod->module_core = ptr; 2794 mod->module_core = ptr;
2795 2795
2796 ptr = module_alloc_update_bounds(mod->init_size); 2796 if (mod->init_size) {
2797 /* 2797 ptr = module_alloc_update_bounds(mod->init_size);
2798 * The pointer to this block is stored in the module structure 2798 /*
2799 * which is inside the block. This block doesn't need to be 2799 * The pointer to this block is stored in the module structure
2800 * scanned as it contains data and code that will be freed 2800 * which is inside the block. This block doesn't need to be
2801 * after the module is initialized. 2801 * scanned as it contains data and code that will be freed
2802 */ 2802 * after the module is initialized.
2803 kmemleak_ignore(ptr); 2803 */
2804 if (!ptr && mod->init_size) { 2804 kmemleak_ignore(ptr);
2805 module_free(mod, mod->module_core); 2805 if (!ptr) {
2806 return -ENOMEM; 2806 module_free(mod, mod->module_core);
2807 } 2807 return -ENOMEM;
2808 memset(ptr, 0, mod->init_size); 2808 }
2809 mod->module_init = ptr; 2809 memset(ptr, 0, mod->init_size);
2810 mod->module_init = ptr;
2811 } else
2812 mod->module_init = NULL;
2810 2813
2811 /* Transfer each section which specifies SHF_ALLOC */ 2814 /* Transfer each section which specifies SHF_ALLOC */
2812 pr_debug("final section addresses:\n"); 2815 pr_debug("final section addresses:\n");