lkml.org 
[lkml]   [2012]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] module: use ZERO_OR_NULL_PTR allocation pointer checking
Date
Use ZERO_OR_NULL_PTR allocation pointer checking where allocation
function may return ZERO_SIZE_PTR.
---
kernel/module.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 2c93276..ae438db 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2322,14 +2322,14 @@ 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)
{
void *ret = module_alloc(size);

- if (ret) {
+ if (likely(!ZERO_OR_NULL_PTR(ret))) {
mutex_lock(&module_mutex);
/* Update module bounds. */
if ((unsigned long)ret < module_addr_min)
@@ -2638,7 +2638,7 @@ static int move_module(struct module *mod, struct load_info *info)
* leak.
*/
kmemleak_not_leak(ptr);
- if (!ptr)
+ if (unlikely(ZERO_OR_NULL_PTR(ptr)))
return -ENOMEM;

memset(ptr, 0, mod->core_size);
@@ -2652,7 +2652,7 @@ static int move_module(struct module *mod, struct load_info *info)
* after the module is initialized.
*/
kmemleak_ignore(ptr);
- if (!ptr && mod->init_size) {
+ if (unlikely(ZERO_OR_NULL_PTR(ptr))) {
module_free(mod, mod->module_core);
return -ENOMEM;
}
--
1.7.7.6


\
 
 \ /
  Last update: 2012-02-28 10:35    [W:0.171 / U:1.984 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site