diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-04-07 10:50:19 (GMT) |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 19:54:40 (GMT) |
commit | 3f5e2d3b3877d34231bbe45856f3b78b7692e472 (patch) | |
tree | bdd3de1a51ab5b4a6529bcc93b30bff39d9d161f /fs/btrfs/qgroup.c | |
parent | b7fef4f593007d52ba7fe4427e099bd71c63c521 (diff) | |
download | linux-fsl-qoriq-3f5e2d3b3877d34231bbe45856f3b78b7692e472.tar.xz |
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>
Diffstat (limited to 'fs/btrfs/qgroup.c')
-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 0932b83..2293da6 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1412,6 +1412,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, struct btrfs_qgroup *srcgroup; struct btrfs_qgroup *dstgroup; u32 level_size = 0; + u64 nums; mutex_lock(&fs_info->qgroup_ioctl_lock); if (!fs_info->quota_enabled) @@ -1422,6 +1423,20 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, goto out; } + if (inherit) { + i_qgroups = (u64 *)(inherit + 1); + nums = inherit->num_qgroups + 2 * inherit->num_ref_copies + + 2 * inherit->num_excl_copies; + for (i = 0; i < nums; ++i) { + srcgroup = find_qgroup_rb(fs_info, *i_qgroups); + if (!srcgroup) { + ret = -EINVAL; + goto out; + } + ++i_qgroups; + } + } + /* * create a tracking group for the subvol itself */ |