diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-03-25 07:08:23 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-03-28 09:51:29 -0400 |
commit | a7975026ff9ddf91ba190ae2b71699dd156395e3 (patch) | |
tree | 6161c6ac3b7a0b2cbcc40b0126c69a261768b4ed /fs/btrfs/qgroup.c | |
parent | fdf30d1c1b386e1b73116cc7e0fb14e962b763b0 (diff) |
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: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/qgroup.c')
-rw-r--r-- | fs/btrfs/qgroup.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 5471e47d6559..b44124dd2370 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -1153,7 +1153,7 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, | |||
1153 | ret = btrfs_find_all_roots(trans, fs_info, node->bytenr, | 1153 | ret = btrfs_find_all_roots(trans, fs_info, node->bytenr, |
1154 | sgn > 0 ? node->seq - 1 : node->seq, &roots); | 1154 | sgn > 0 ? node->seq - 1 : node->seq, &roots); |
1155 | if (ret < 0) | 1155 | if (ret < 0) |
1156 | goto out; | 1156 | return ret; |
1157 | 1157 | ||
1158 | spin_lock(&fs_info->qgroup_lock); | 1158 | spin_lock(&fs_info->qgroup_lock); |
1159 | quota_root = fs_info->quota_root; | 1159 | quota_root = fs_info->quota_root; |
@@ -1275,7 +1275,6 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, | |||
1275 | ret = 0; | 1275 | ret = 0; |
1276 | unlock: | 1276 | unlock: |
1277 | spin_unlock(&fs_info->qgroup_lock); | 1277 | spin_unlock(&fs_info->qgroup_lock); |
1278 | out: | ||
1279 | ulist_free(roots); | 1278 | ulist_free(roots); |
1280 | ulist_free(tmp); | 1279 | ulist_free(tmp); |
1281 | 1280 | ||