Commit d4031259 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

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: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 2257e468
...@@ -1722,13 +1722,13 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) ...@@ -1722,13 +1722,13 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
struct gfs2_inode *ip; struct gfs2_inode *ip;
ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
if (ip) { if (!ip)
return NULL;
ip->i_flags = 0; ip->i_flags = 0;
ip->i_gl = NULL; ip->i_gl = NULL;
memset(&ip->i_res, 0, sizeof(ip->i_res)); memset(&ip->i_res, 0, sizeof(ip->i_res));
RB_CLEAR_NODE(&ip->i_res.rs_node); RB_CLEAR_NODE(&ip->i_res.rs_node);
ip->i_rahead = 0; ip->i_rahead = 0;
}
return &ip->i_inode; return &ip->i_inode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment