Skip to content

Commit

Permalink
ocfs2: fix mutex_unlock and possible memory leak in ocfs2_remove_btre…
Browse files Browse the repository at this point in the history
…e_range

In ocfs2_remove_btree_range, when calling ocfs2_lock_refcount_tree and
ocfs2_prepare_refcount_change_for_del failed, it goes to out and then
tries to call mutex_unlock without mutex_lock before.  And when calling
ocfs2_reserve_blocks_for_rec_trunc failed, it should free ref_tree
before return.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Joseph Qi authored and Linus Torvalds committed Jul 3, 2013
1 parent 8fa9d17 commit 33add0e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5655,7 +5655,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
&ref_tree, NULL);
if (ret) {
mlog_errno(ret);
goto out;
goto bail;
}

ret = ocfs2_prepare_refcount_change_for_del(inode,
Expand All @@ -5666,15 +5666,15 @@ int ocfs2_remove_btree_range(struct inode *inode,
&extra_blocks);
if (ret < 0) {
mlog_errno(ret);
goto out;
goto bail;
}
}

ret = ocfs2_reserve_blocks_for_rec_trunc(inode, et, 1, &meta_ac,
extra_blocks);
if (ret) {
mlog_errno(ret);
return ret;
goto bail;
}

mutex_lock(&tl_inode->i_mutex);
Expand Down Expand Up @@ -5734,7 +5734,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
ocfs2_commit_trans(osb, handle);
out:
mutex_unlock(&tl_inode->i_mutex);

bail:
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);

Expand Down

0 comments on commit 33add0e

Please sign in to comment.