mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: Emil Goode <emilgoode@gmail.com>
Cc: swhiteho@redhat.com, cluster-devel@redhat.com,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] GFS2: Return -ENOMEM only if kmalloc fails
Date: Thu, 26 Apr 2012 23:14:02 +0200	[thread overview]
Message-ID: <201204262314.02683.oliver@neukum.org> (raw)
In-Reply-To: <1335474778-6252-1-git-send-email-emilgoode@gmail.com>

Am Donnerstag, 26. April 2012, 23:12:58 schrieb Emil Goode:
> The error variable should be assigned the value of -ENOMEM
> after the NULL check and not before.
> 
> Signed-off-by: Emil Goode <emilgoode@gmail.com>
> ---
>  fs/gfs2/acl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
> index 230eb0f..90f6328 100644
> --- a/fs/gfs2/acl.c
> +++ b/fs/gfs2/acl.c
> @@ -174,8 +174,8 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
>  
>  	len = posix_acl_to_xattr(acl, NULL, 0);
>  	data = kmalloc(len, GFP_NOFS);
> -	error = -ENOMEM;
>  	if (data == NULL)
> +		error = -ENOMEM;
>  		goto out;

Hint: read about the syntax of the if statement.
Secondly, consider how the compiler can optimize the original.

	Regards
		Oliver

  reply	other threads:[~2012-04-26 21:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 21:12 Emil Goode
2012-04-26 21:14 ` Oliver Neukum [this message]
2012-04-26 21:30   ` Emil Goode
2012-04-26 21:19 ` Dave Jones

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=201204262314.02683.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=cluster-devel@redhat.com \
    --cc=emilgoode@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swhiteho@redhat.com \
    /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

Powered by JetHome