From: Dmitry Antipov <dmitry.antipov@linaro.org>
To: Rusty Russell <rusty.russell@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linaro-dev@lists.linaro.org, patches@linaro.org,
Dmitry Antipov <dmitry.antipov@linaro.org>
Subject: [PATCH 2/2] module: use ZERO_OR_NULL_PTR allocation pointer checking
Date: Tue, 28 Feb 2012 13:34:00 +0400 [thread overview]
Message-ID: <1330421640-5137-2-git-send-email-dmitry.antipov@linaro.org> (raw)
In-Reply-To: <1330421640-5137-1-git-send-email-dmitry.antipov@linaro.org>
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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-02-28 9:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 9:33 [PATCH 1/2] vmalloc: use ZERO_SIZE_PTR / ZERO_OR_NULL_PTR Dmitry Antipov
2012-02-28 9:34 ` Dmitry Antipov [this message]
2012-02-28 9:44 ` Dan Carpenter
2012-02-28 11:59 ` Dmitry Antipov
2012-02-28 13:30 ` Dan Carpenter
2012-02-29 6:53 ` Dmitry Antipov
2012-02-29 7:10 ` Dan Carpenter
2012-02-29 8:29 ` Amit Kucheria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330421640-5137-2-git-send-email-dmitry.antipov@linaro.org \
--to=dmitry.antipov@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=patches@linaro.org \
--cc=rusty.russell@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).