linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Dmitry Antipov <dmitry.antipov@linaro.org>
Cc: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org,
	patches@linaro.org, Dmitry Antipov <dmitry.antipov@linaro.org>
Subject: Re: [PATCH 3/3] module: use ZERO_OR_NULL_PTR allocation pointer checking
Date: Tue, 31 Jan 2012 09:42:52 +1030	[thread overview]
Message-ID: <87ty3clr7v.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1327913080-8850-1-git-send-email-dmitry.antipov@linaro.org>

On Mon, 30 Jan 2012 12:44:40 +0400, Dmitry Antipov <dmitry.antipov@linaro.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@linaro.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.

      reply	other threads:[~2012-01-31  1:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30  8:44 [PATCH 3/3] module: use ZERO_OR_NULL_PTR allocation pointer checking Dmitry Antipov
2012-01-30 23:12 ` Rusty Russell [this message]

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=87ty3clr7v.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=dmitry.antipov@linaro.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@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).