Commit b1214e47 authored by Xue jiufei's avatar Xue jiufei Committed by Linus Torvalds

ocfs2: fix possible double free in ocfs2_write_begin_nolock

When ocfs2_write_cluster_by_desc() failed in ocfs2_write_begin_nolock()
because of ENOSPC, it goes to out_quota, freeing data_ac(meta_ac).  Then
it calls ocfs2_try_to_free_truncate_log() to free space.  If enough
space freed, it will try to write again.  Unfortunately, some error
happenes before ocfs2_lock_allocators(), it goes to out and free
data_ac(meta_ac) again.
Signed-off-by: default avatarjoyce <xuejiufei@huawei.com>
Reviewed-by: default avatarJie Liu <jeff.liu@oracle.com>
Acked-by: default avatarJoel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bfbca926
......@@ -1898,10 +1898,14 @@ int ocfs2_write_begin_nolock(struct file *filp,
out:
ocfs2_free_write_ctxt(wc);
if (data_ac)
if (data_ac) {
ocfs2_free_alloc_context(data_ac);
if (meta_ac)
data_ac = NULL;
}
if (meta_ac) {
ocfs2_free_alloc_context(meta_ac);
meta_ac = NULL;
}
if (ret == -ENOSPC && try_free) {
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment