Skip to content

Commit 5879620

Browse files
Rui Xiangtorvalds
authored andcommitted
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>
1 parent 7391a29 commit 5879620

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎fs/ocfs2/refcounttree.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
612612
}
613613

614614
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+
}
615620
ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh);
616621

617622
ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh,

‎fs/ocfs2/xattr.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode,
28642864
}
28652865

28662866
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+
28672873
ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
28682874

28692875
ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),

0 commit comments

Comments
 (0)