Skip to content

Commit

Permalink
ocfs2: add necessary check in case sb_getblk() fails
Browse files Browse the repository at this point in the history
sb_getblk() may return an err, so add a check for bh.

[[email protected]: also add a check after calling sb_getblk() in ocfs2_create_xattr_block()]
Signed-off-by: Rui Xiang <[email protected]>
Reviewed-by: Jie Liu <[email protected]>
Reviewed-by: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Joseph Qi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Rui Xiang authored and torvalds committed Nov 13, 2013
1 parent 7391a29 commit 5879620
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/ocfs2/refcounttree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 5879620

Please sign in to comment.