Commit 0afb603a authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues Committed by David Sterba

btrfs: allocate btrfs_ioctl_quota_rescan_args on stack

Instead of using kmalloc() to allocate btrfs_ioctl_quota_rescan_args,
allocate btrfs_ioctl_quota_rescan_args on stack, the size is reasonably
small and ioctls are called in process context.

sizeof(btrfs_ioctl_quota_rescan_args) = 64
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 98caf953
...@@ -4403,25 +4403,20 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg) ...@@ -4403,25 +4403,20 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info, static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info,
void __user *arg) void __user *arg)
{ {
struct btrfs_ioctl_quota_rescan_args *qsa; struct btrfs_ioctl_quota_rescan_args qsa = {0};
int ret = 0; int ret = 0;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
qsa = kzalloc(sizeof(*qsa), GFP_KERNEL);
if (!qsa)
return -ENOMEM;
if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) { if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) {
qsa->flags = 1; qsa.flags = 1;
qsa->progress = fs_info->qgroup_rescan_progress.objectid; qsa.progress = fs_info->qgroup_rescan_progress.objectid;
} }
if (copy_to_user(arg, qsa, sizeof(*qsa))) if (copy_to_user(arg, &qsa, sizeof(qsa)))
ret = -EFAULT; ret = -EFAULT;
kfree(qsa);
return ret; return ret;
} }
......
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