diff mbox

[2/2] ocfs2: add necessary check in case sb_getblk fails

Message ID 1378191640-3844-2-git-send-email-rui.xiang@huawei.com
State New, archived
Headers show

Commit Message

Rui Xiang Sept. 3, 2013, 7 a.m. UTC
Sb_getblk may retrun an err, so add a check for bh.

Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
---
 fs/ocfs2/refcounttree.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

jeff.liu Sept. 3, 2013, 8:16 a.m. UTC | #1
On 09/03/2013 03:00 PM, Rui Xiang wrote:

> Sb_getblk may retrun an err, so add a check for bh.
> 
> Signed-off-by: Rui Xiang <rui.xiang@huawei.com>

Reviewed-by: Jie Liu <jeff.liu@oracle.com>

> ---
>  fs/ocfs2/refcounttree.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 50c1796..22f3f19 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 mbox

Patch

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 50c1796..22f3f19 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,