aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Qi <joseph.qi@huawei.com>2013-07-03 18:00:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:23 -0400
commit33add0e3a09a62c7796ea9838243c1cd933d8543 (patch)
treeb3f8df10c52c784f5e3b68639b4507e54f3d31ac
parent8fa9d17f93ee8eb79d595c98cef0944f6ee5de75 (diff)
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 <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>
-rw-r--r--fs/ocfs2/alloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index b8a9d87231b1..17e6bdde96c5 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -5655,7 +5655,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
5655 &ref_tree, NULL); 5655 &ref_tree, NULL);
5656 if (ret) { 5656 if (ret) {
5657 mlog_errno(ret); 5657 mlog_errno(ret);
5658 goto out; 5658 goto bail;
5659 } 5659 }
5660 5660
5661 ret = ocfs2_prepare_refcount_change_for_del(inode, 5661 ret = ocfs2_prepare_refcount_change_for_del(inode,
@@ -5666,7 +5666,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
5666 &extra_blocks); 5666 &extra_blocks);
5667 if (ret < 0) { 5667 if (ret < 0) {
5668 mlog_errno(ret); 5668 mlog_errno(ret);
5669 goto out; 5669 goto bail;
5670 } 5670 }
5671 } 5671 }
5672 5672
@@ -5674,7 +5674,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
5674 extra_blocks); 5674 extra_blocks);
5675 if (ret) { 5675 if (ret) {
5676 mlog_errno(ret); 5676 mlog_errno(ret);
5677 return ret; 5677 goto bail;
5678 } 5678 }
5679 5679
5680 mutex_lock(&tl_inode->i_mutex); 5680 mutex_lock(&tl_inode->i_mutex);
@@ -5734,7 +5734,7 @@ out_commit:
5734 ocfs2_commit_trans(osb, handle); 5734 ocfs2_commit_trans(osb, handle);
5735out: 5735out:
5736 mutex_unlock(&tl_inode->i_mutex); 5736 mutex_unlock(&tl_inode->i_mutex);
5737 5737bail:
5738 if (meta_ac) 5738 if (meta_ac)
5739 ocfs2_free_alloc_context(meta_ac); 5739 ocfs2_free_alloc_context(meta_ac);
5740 5740