Commit 58796207 authored by Rui Xiang's avatar Rui Xiang Committed by Linus Torvalds

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: default avatarRui Xiang <rui.xiang@huawei.com>
Reviewed-by: default avatarJie Liu <jeff.liu@oracle.com>
Reviewed-by: default avatarMark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7391a294
...@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode, ...@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
} }
new_bh = sb_getblk(inode->i_sb, first_blkno); 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); ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh);
ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh, ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh,
......
...@@ -2864,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode, ...@@ -2864,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode,
} }
new_bh = sb_getblk(inode->i_sb, first_blkno); 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); ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode), ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(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