Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7975026 authored by Wang Shilong's avatar Wang Shilong Committed by Josef Bacik
Browse files

Btrfs: fix double free in the btrfs_qgroup_account_ref()



The function btrfs_find_all_roots is responsible to allocate
memory for 'roots' and free it if errors happen,so the caller should not
free it again since the work has been done.

Besides,'tmp' is allocated after the function btrfs_find_all_roots,
so we can return directly if btrfs_find_all_roots() fails.

Signed-off-by: default avatarWang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Reviewed-by: default avatarJan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent fdf30d1c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1153,7 +1153,7 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans,
	ret = btrfs_find_all_roots(trans, fs_info, node->bytenr,
				   sgn > 0 ? node->seq - 1 : node->seq, &roots);
	if (ret < 0)
		goto out;
		return ret;

	spin_lock(&fs_info->qgroup_lock);
	quota_root = fs_info->quota_root;
@@ -1275,7 +1275,6 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans,
	ret = 0;
unlock:
	spin_unlock(&fs_info->qgroup_lock);
out:
	ulist_free(roots);
	ulist_free(tmp);