From: Rui Xiang Date: Tue, 12 Nov 2013 23:06:55 +0000 (-0800) Subject: ocfs2: add necessary check in case sb_getblk() fails X-Git-Tag: accepted/tizen/common/20141203.182822~1142^2~259 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=58796207cf09552706b0c3e0669f2ce52ea6cee1;p=platform%2Fkernel%2Flinux-arm64.git ocfs2: add necessary check in case sb_getblk() fails sb_getblk() may return an err, so add a check for bh. [joseph.qi@huawei.com: also add a check after calling sb_getblk() in ocfs2_create_xattr_block()] Signed-off-by: Rui Xiang Reviewed-by: Jie Liu Reviewed-by: Mark Fasheh Cc: Joel Becker Cc: Joseph Qi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 70d083e..55767e1 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode, } new_bh = sb_getblk(inode->i_sb, first_blkno); + if (!new_bh) { + ret = -ENOMEM; + mlog_errno(ret); + goto out_commit; + } ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh); ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh, diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 8225729..f0a1326 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -2864,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode, } new_bh = sb_getblk(inode->i_sb, first_blkno); + if (!new_bh) { + ret = -ENOMEM; + mlog_errno(ret); + goto end; + } + ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),