From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] GFS2: Improve readability of gfs2_alloc_inode
Date: Tue, 3 Mar 2015 09:57:59 -0500 (EST) [thread overview]
Message-ID: <942241918.22798702.1425394679929.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1425317501-23593-1-git-send-email-anprice@redhat.com>
----- Original Message -----
> Returning &ip->i_inode when ip is NULL is safe as i_inode is the first
> member in struct gfs2_inode, but that's not immediately obvious.
> Reorganize gfs2_alloc_inode to avoid any doubt.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>
> Re-sending with a more appropriate commit log based on Andreas' comments.
>
> 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;
> }
>
> --
> 1.9.3
ACK,
Bob Peterson
Red Hat File Systems
prev parent reply other threads:[~2015-03-03 14:57 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
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 [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=942241918.22798702.1425394679929.JavaMail.zimbra@redhat.com \
--to=rpeterso@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;
as well as URLs for NNTP newsgroup(s).