Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242562
b: refs/heads/master
c: 6bb43b5
h: refs/heads/master
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Mar 24, 2011
1 parent cc6bbfc commit 831bb99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: de8be5ac70f50a2340f24fd769a1aafa5a51ae34
refs/heads/master: 6bb43b5d1f54fb44c0408d86d5e71e4405a3ebe1
25 changes: 11 additions & 14 deletions trunk/drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,11 +1501,6 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
return r;
}

static void free_params(struct dm_ioctl *param)
{
vfree(param);
}

static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
{
struct dm_ioctl tmp, *dmi;
Expand All @@ -1520,13 +1515,15 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
if (!dmi)
return -ENOMEM;

if (copy_from_user(dmi, user, tmp.data_size)) {
vfree(dmi);
return -EFAULT;
}
if (copy_from_user(dmi, user, tmp.data_size))
goto bad;

*param = dmi;
return 0;

bad:
vfree(dmi);
return -EFAULT;
}

static int validate_params(uint cmd, struct dm_ioctl *param)
Expand Down Expand Up @@ -1564,7 +1561,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
unsigned int cmd;
struct dm_ioctl *uninitialized_var(param);
ioctl_fn fn = NULL;
size_t param_size;
size_t input_param_size;

/* only root can play with this */
if (!capable(CAP_SYS_ADMIN))
Expand Down Expand Up @@ -1605,6 +1602,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
* Copy the parameters into kernel space.
*/
r = copy_params(user, &param);
input_param_size = param->data_size;

current->flags &= ~PF_MEMALLOC;

Expand All @@ -1615,18 +1613,17 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
if (r)
goto out;

param_size = param->data_size;
param->data_size = sizeof(*param);
r = fn(param, param_size);
r = fn(param, input_param_size);

/*
* Copy the results back to userland.
*/
if (!r && copy_to_user(user, param, param->data_size))
r = -EFAULT;

out:
free_params(param);
out:
vfree(param);
return r;
}

Expand Down

0 comments on commit 831bb99

Please sign in to comment.