Skip to content

Commit 33add0e

Browse files
josephhztorvalds
authored andcommitted
ocfs2: fix mutex_unlock and possible memory leak in ocfs2_remove_btree_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 <[email protected]> Reviewed-by: Jie Liu <[email protected]> Cc: Joel Becker <[email protected]> Cc: Mark Fasheh <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8fa9d17 commit 33add0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/ocfs2/alloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5655,7 +5655,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
56555655
&ref_tree, NULL);
56565656
if (ret) {
56575657
mlog_errno(ret);
5658-
goto out;
5658+
goto bail;
56595659
}
56605660

56615661
ret = ocfs2_prepare_refcount_change_for_del(inode,
@@ -5666,15 +5666,15 @@ int ocfs2_remove_btree_range(struct inode *inode,
56665666
&extra_blocks);
56675667
if (ret < 0) {
56685668
mlog_errno(ret);
5669-
goto out;
5669+
goto bail;
56705670
}
56715671
}
56725672

56735673
ret = ocfs2_reserve_blocks_for_rec_trunc(inode, et, 1, &meta_ac,
56745674
extra_blocks);
56755675
if (ret) {
56765676
mlog_errno(ret);
5677-
return ret;
5677+
goto bail;
56785678
}
56795679

56805680
mutex_lock(&tl_inode->i_mutex);
@@ -5734,7 +5734,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
57345734
ocfs2_commit_trans(osb, handle);
57355735
out:
57365736
mutex_unlock(&tl_inode->i_mutex);
5737-
5737+
bail:
57385738
if (meta_ac)
57395739
ocfs2_free_alloc_context(meta_ac);
57405740

0 commit comments

Comments
 (0)