From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] GFS2: Fix potential NULL dereference in gfs2_alloc_inode
Date: Mon, 2 Mar 2015 16:15:08 +0000 [thread overview]
Message-ID: <1425312908-21017-1-git-send-email-anprice@redhat.com> (raw)
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;
}
--
1.9.3
next reply other threads:[~2015-03-02 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 16:15 Andrew Price [this message]
2015-03-02 16:17 ` [Cluster-devel] [PATCH] GFS2: Fix potential NULL dereference in gfs2_alloc_inode 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
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=1425312908-21017-1-git-send-email-anprice@redhat.com \
--to=anprice@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).