diff options
author | Rui Xiang <rui.xiang@huawei.com> | 2013-11-12 18:06:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:00 -0500 |
commit | 58796207cf09552706b0c3e0669f2ce52ea6cee1 (patch) | |
tree | c3023177cd5414a1199da59ba8d52f74f7a64d32 | |
parent | 7391a294b861bf2c3b762dfdcf61b9c5f1bffa1f (diff) |
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 <rui.xiang@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ocfs2/refcounttree.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 70d083e60d40..55767e1ba724 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode, | |||
612 | } | 612 | } |
613 | 613 | ||
614 | new_bh = sb_getblk(inode->i_sb, first_blkno); | 614 | new_bh = sb_getblk(inode->i_sb, first_blkno); |
615 | if (!new_bh) { | ||
616 | ret = -ENOMEM; | ||
617 | mlog_errno(ret); | ||
618 | goto out_commit; | ||
619 | } | ||
615 | ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh); | 620 | ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh); |
616 | 621 | ||
617 | ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh, | 622 | 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 82257299d5ea..f0a1326d9bba 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -2864,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode, | |||
2864 | } | 2864 | } |
2865 | 2865 | ||
2866 | new_bh = sb_getblk(inode->i_sb, first_blkno); | 2866 | new_bh = sb_getblk(inode->i_sb, first_blkno); |
2867 | if (!new_bh) { | ||
2868 | ret = -ENOMEM; | ||
2869 | mlog_errno(ret); | ||
2870 | goto end; | ||
2871 | } | ||
2872 | |||
2867 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); | 2873 | ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); |
2868 | 2874 | ||
2869 | ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode), | 2875 | ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode), |