From 595cf7060155a7e564e380c7d6fffb6d3565110f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 11 Dec 2012 09:38:33 +1030 Subject: [PATCH] --- yaml --- r: 347103 b: refs/heads/master c: 82fab442f5322b016f72891c0db2436c6a6c20b7 h: refs/heads/master i: 347101: bb3fb31bdbfb72611ad5534f2f0d198e3e852191 347099: cc63df4da3713223f584d39c734263818923f3cd 347095: 7beba75378889ed205cf0bbed7318f34e252677d 347087: 6b42f1b153e34d8e2023f54623fb8830d1cb9851 347071: d2e2e6deb94ed046439d27bcefb65b47f0e0d6b8 v: v3 --- [refs] | 2 +- trunk/arch/cris/kernel/module.c | 2 -- trunk/arch/parisc/kernel/module.c | 2 -- trunk/arch/sparc/kernel/module.c | 4 ---- trunk/arch/tile/kernel/module.c | 2 -- trunk/arch/unicore32/kernel/module.c | 3 --- trunk/kernel/module.c | 33 +++++++++++++++------------- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/[refs] b/[refs] index 2c944e26d4e3..bd06a4f41cd5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 54523ec71f8ce99accae97c74152f14f261f7e18 +refs/heads/master: 82fab442f5322b016f72891c0db2436c6a6c20b7 diff --git a/trunk/arch/cris/kernel/module.c b/trunk/arch/cris/kernel/module.c index 37400f5869e6..51123f985eb5 100644 --- a/trunk/arch/cris/kernel/module.c +++ b/trunk/arch/cris/kernel/module.c @@ -32,8 +32,6 @@ #ifdef CONFIG_ETRAX_KMALLOCED_MODULES void *module_alloc(unsigned long size) { - if (size == 0) - return NULL; return kmalloc(size, GFP_KERNEL); } diff --git a/trunk/arch/parisc/kernel/module.c b/trunk/arch/parisc/kernel/module.c index 5e34ccf39a49..2a625fb063e1 100644 --- a/trunk/arch/parisc/kernel/module.c +++ b/trunk/arch/parisc/kernel/module.c @@ -214,8 +214,6 @@ static inline int reassemble_22(int as22) void *module_alloc(unsigned long size) { - if (size == 0) - return NULL; /* using RWX means less protection for modules, but it's * easier than trying to map the text, data, init_text and * init_data correctly */ diff --git a/trunk/arch/sparc/kernel/module.c b/trunk/arch/sparc/kernel/module.c index f1ddc0d23679..4435488ebe25 100644 --- a/trunk/arch/sparc/kernel/module.c +++ b/trunk/arch/sparc/kernel/module.c @@ -43,10 +43,6 @@ void *module_alloc(unsigned long size) { void *ret; - /* We handle the zero case fine, unlike vmalloc */ - if (size == 0) - return NULL; - ret = module_map(size); if (ret) memset(ret, 0, size); diff --git a/trunk/arch/tile/kernel/module.c b/trunk/arch/tile/kernel/module.c index 243ffebe38d6..4918d91bc3a6 100644 --- a/trunk/arch/tile/kernel/module.c +++ b/trunk/arch/tile/kernel/module.c @@ -42,8 +42,6 @@ void *module_alloc(unsigned long size) int i = 0; int npages; - if (size == 0) - return NULL; npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL); if (pages == NULL) diff --git a/trunk/arch/unicore32/kernel/module.c b/trunk/arch/unicore32/kernel/module.c index 8fbe8577f5e6..16bd1495b934 100644 --- a/trunk/arch/unicore32/kernel/module.c +++ b/trunk/arch/unicore32/kernel/module.c @@ -27,9 +27,6 @@ void *module_alloc(unsigned long size) struct vm_struct *area; size = PAGE_ALIGN(size); - if (!size) - return NULL; - area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END); if (!area) return NULL; diff --git a/trunk/kernel/module.c b/trunk/kernel/module.c index 79a526dd1b11..4542ff3f7ef9 100644 --- a/trunk/kernel/module.c +++ b/trunk/kernel/module.c @@ -2377,7 +2377,7 @@ static void dynamic_debug_remove(struct _ddebug *debug) void * __weak module_alloc(unsigned long size) { - return size == 0 ? NULL : vmalloc_exec(size); + return vmalloc_exec(size); } static void *module_alloc_update_bounds(unsigned long size) @@ -2793,20 +2793,23 @@ static int move_module(struct module *mod, struct load_info *info) memset(ptr, 0, mod->core_size); mod->module_core = ptr; - ptr = module_alloc_update_bounds(mod->init_size); - /* - * The pointer to this block is stored in the module structure - * which is inside the block. This block doesn't need to be - * scanned as it contains data and code that will be freed - * after the module is initialized. - */ - kmemleak_ignore(ptr); - if (!ptr && mod->init_size) { - module_free(mod, mod->module_core); - return -ENOMEM; - } - memset(ptr, 0, mod->init_size); - mod->module_init = ptr; + if (mod->init_size) { + ptr = module_alloc_update_bounds(mod->init_size); + /* + * The pointer to this block is stored in the module structure + * which is inside the block. This block doesn't need to be + * scanned as it contains data and code that will be freed + * after the module is initialized. + */ + kmemleak_ignore(ptr); + if (!ptr) { + module_free(mod, mod->module_core); + return -ENOMEM; + } + memset(ptr, 0, mod->init_size); + mod->module_init = ptr; + } else + mod->module_init = NULL; /* Transfer each section which specifies SHF_ALLOC */ pr_debug("final section addresses:\n");