diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-04-07 06:50:19 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:54:40 -0400 |
commit | 3f5e2d3b3877d34231bbe45856f3b78b7692e472 (patch) | |
tree | bdd3de1a51ab5b4a6529bcc93b30bff39d9d161f | |
parent | b7fef4f593007d52ba7fe4427e099bd71c63c521 (diff) |
Btrfs: fix missing check in the btrfs_qgroup_inherit()
The original code forgot to check 'inherit', we should
gurantee that all the qgroups in the struct 'inherit' exist.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r-- | fs/btrfs/qgroup.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 0932b839550c..2293da6f9e72 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -1412,6 +1412,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, | |||
1412 | struct btrfs_qgroup *srcgroup; | 1412 | struct btrfs_qgroup *srcgroup; |
1413 | struct btrfs_qgroup *dstgroup; | 1413 | struct btrfs_qgroup *dstgroup; |
1414 | u32 level_size = 0; | 1414 | u32 level_size = 0; |
1415 | u64 nums; | ||
1415 | 1416 | ||
1416 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 1417 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
1417 | if (!fs_info->quota_enabled) | 1418 | if (!fs_info->quota_enabled) |
@@ -1422,6 +1423,20 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, | |||
1422 | goto out; | 1423 | goto out; |
1423 | } | 1424 | } |
1424 | 1425 | ||
1426 | if (inherit) { | ||
1427 | i_qgroups = (u64 *)(inherit + 1); | ||
1428 | nums = inherit->num_qgroups + 2 * inherit->num_ref_copies + | ||
1429 | 2 * inherit->num_excl_copies; | ||
1430 | for (i = 0; i < nums; ++i) { | ||
1431 | srcgroup = find_qgroup_rb(fs_info, *i_qgroups); | ||
1432 | if (!srcgroup) { | ||
1433 | ret = -EINVAL; | ||
1434 | goto out; | ||
1435 | } | ||
1436 | ++i_qgroups; | ||
1437 | } | ||
1438 | } | ||
1439 | |||
1425 | /* | 1440 | /* |
1426 | * create a tracking group for the subvol itself | 1441 | * create a tracking group for the subvol itself |
1427 | */ | 1442 | */ |