[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87ty3clr7v.fsf@rustcorp.com.au>
Date: Tue, 31 Jan 2012 09:42:52 +1030
From: Rusty Russell <rusty@...tcorp.com.au>
To: Dmitry Antipov <dmitry.antipov@...aro.org>
Cc: linux-kernel@...r.kernel.org, linaro-dev@...ts.linaro.org,
patches@...aro.org, Dmitry Antipov <dmitry.antipov@...aro.org>
Subject: Re: [PATCH 3/3] module: use ZERO_OR_NULL_PTR allocation pointer checking
On Mon, 30 Jan 2012 12:44:40 +0400, Dmitry Antipov <dmitry.antipov@...aro.org> wrote:
> Use ZERO_OR_NULL_PTR allocation pointer checking where allocation
> function may return ZERO_SIZE_PTR.
>
> Signed-off-by: Dmitry Antipov <dmitry.antipov@...aro.org>
> ---
> kernel/module.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 2c93276..5183f91 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -438,7 +438,7 @@ static int percpu_modalloc(struct module *mod,
> }
>
> mod->percpu = __alloc_reserved_percpu(size, align);
> - if (!mod->percpu) {
> + if (unlikely(ZERO_OR_NULL_PTR(mod->percpu))) {
> printk(KERN_WARNING
> "%s: Could not allocate %lu bytes percpu data\n",
> mod->name, size);
printk() is marked __cold. You don't need unlikely() here.
> @@ -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)) && mod->init_size) {
> module_free(mod, mod->module_core);
> return -ENOMEM;
> }
You want to just change this to:
if (!ptr) {
Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists