diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2019-07-24 07:05:38 -0400 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2019-08-09 12:00:52 -0400 |
commit | d40312598d534c17c17f41c2bb7ce9541a5f786e (patch) | |
tree | 1000d342c7639188e45a3374392e311404777a84 | |
parent | 2257e468a63b6d35a77e884ef032c54f9be65c92 (diff) |
gfs2: Minor gfs2_alloc_inode cleanup
In gfs2_alloc_inode, when kmem_cache_alloc cannot allocate a new object, return
NULL immediately. The code currently relies on the fact that i_inode is the
first member in struct gfs2_inode and so ip and &ip->i_inode evaluate to the
same address, but that isn't immediately obvious.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r-- | fs/gfs2/super.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 0acc5834f653..644c70ae09f7 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -1722,13 +1722,13 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) | |||
1722 | struct gfs2_inode *ip; | 1722 | struct gfs2_inode *ip; |
1723 | 1723 | ||
1724 | ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); | 1724 | ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); |
1725 | if (ip) { | 1725 | if (!ip) |
1726 | ip->i_flags = 0; | 1726 | return NULL; |
1727 | ip->i_gl = NULL; | 1727 | ip->i_flags = 0; |
1728 | memset(&ip->i_res, 0, sizeof(ip->i_res)); | 1728 | ip->i_gl = NULL; |
1729 | RB_CLEAR_NODE(&ip->i_res.rs_node); | 1729 | memset(&ip->i_res, 0, sizeof(ip->i_res)); |
1730 | ip->i_rahead = 0; | 1730 | RB_CLEAR_NODE(&ip->i_res.rs_node); |
1731 | } | 1731 | ip->i_rahead = 0; |
1732 | return &ip->i_inode; | 1732 | return &ip->i_inode; |
1733 | } | 1733 | } |
1734 | 1734 | ||