All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] GFS2: Fix potential NULL dereference in gfs2_alloc_inode
Date: Mon, 02 Mar 2015 16:17:39 +0000	[thread overview]
Message-ID: <54F48D23.900@redhat.com> (raw)
In-Reply-To: <1425312908-21017-1-git-send-email-anprice@redhat.com>

Hi,

On 02/03/15 16:15, Andrew Price wrote:
> Return NULL when ip is NULL instead of dereferencing it.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>   fs/gfs2/super.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index 1666382..37c59ee 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -1628,12 +1628,13 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
>   	struct gfs2_inode *ip;
>   
>   	ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
> -	if (ip) {
> -		ip->i_flags = 0;
> -		ip->i_gl = NULL;
> -		ip->i_rgd = NULL;
> -		ip->i_res = NULL;
> -	}
> +	if (!ip)
> +		return NULL;
> +
> +	ip->i_flags = 0;
> +	ip->i_gl = NULL;
> +	ip->i_rgd = NULL;
> +	ip->i_res = NULL;
>   	return &ip->i_inode;
>   }
>   

I'm not sure that I see the problem here... it should just return NULL 
if ip is NULL, since ip->i_inode is the first element of ip,

Steve.



  reply	other threads:[~2015-03-02 16:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 16:15 [Cluster-devel] [PATCH] GFS2: Fix potential NULL dereference in gfs2_alloc_inode Andrew Price
2015-03-02 16:17 ` Steven Whitehouse [this message]
2015-03-02 16:30   ` Andrew Price
2015-03-02 17:05     ` Andreas Gruenbacher
2015-03-02 17:31       ` [Cluster-devel] [PATCH] GFS2: Improve readability of gfs2_alloc_inode Andrew Price
2015-03-03 14:57         ` Bob Peterson

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=54F48D23.900@redhat.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.