diff options
author | Milan Broz <mbroz@redhat.com> | 2011-03-24 09:54:28 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-03-24 09:54:28 -0400 |
commit | 6bb43b5d1f54fb44c0408d86d5e71e4405a3ebe1 (patch) | |
tree | f32946848c23dda73b72178c292567a4e06176b5 /drivers/md/dm-ioctl.c | |
parent | de8be5ac70f50a2340f24fd769a1aafa5a51ae34 (diff) |
dm ioctl: prepare for crypt key wiping
Prepare code for implementing buffer wipe flag.
No functional change in this patch.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 6d12775a1061..3a8f6a0e6eb5 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -1501,11 +1501,6 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user) | |||
1501 | return r; | 1501 | return r; |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | static void free_params(struct dm_ioctl *param) | ||
1505 | { | ||
1506 | vfree(param); | ||
1507 | } | ||
1508 | |||
1509 | static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) | 1504 | static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) |
1510 | { | 1505 | { |
1511 | struct dm_ioctl tmp, *dmi; | 1506 | struct dm_ioctl tmp, *dmi; |
@@ -1520,13 +1515,15 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) | |||
1520 | if (!dmi) | 1515 | if (!dmi) |
1521 | return -ENOMEM; | 1516 | return -ENOMEM; |
1522 | 1517 | ||
1523 | if (copy_from_user(dmi, user, tmp.data_size)) { | 1518 | if (copy_from_user(dmi, user, tmp.data_size)) |
1524 | vfree(dmi); | 1519 | goto bad; |
1525 | return -EFAULT; | ||
1526 | } | ||
1527 | 1520 | ||
1528 | *param = dmi; | 1521 | *param = dmi; |
1529 | return 0; | 1522 | return 0; |
1523 | |||
1524 | bad: | ||
1525 | vfree(dmi); | ||
1526 | return -EFAULT; | ||
1530 | } | 1527 | } |
1531 | 1528 | ||
1532 | static int validate_params(uint cmd, struct dm_ioctl *param) | 1529 | static int validate_params(uint cmd, struct dm_ioctl *param) |
@@ -1564,7 +1561,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) | |||
1564 | unsigned int cmd; | 1561 | unsigned int cmd; |
1565 | struct dm_ioctl *uninitialized_var(param); | 1562 | struct dm_ioctl *uninitialized_var(param); |
1566 | ioctl_fn fn = NULL; | 1563 | ioctl_fn fn = NULL; |
1567 | size_t param_size; | 1564 | size_t input_param_size; |
1568 | 1565 | ||
1569 | /* only root can play with this */ | 1566 | /* only root can play with this */ |
1570 | if (!capable(CAP_SYS_ADMIN)) | 1567 | if (!capable(CAP_SYS_ADMIN)) |
@@ -1605,6 +1602,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) | |||
1605 | * Copy the parameters into kernel space. | 1602 | * Copy the parameters into kernel space. |
1606 | */ | 1603 | */ |
1607 | r = copy_params(user, ¶m); | 1604 | r = copy_params(user, ¶m); |
1605 | input_param_size = param->data_size; | ||
1608 | 1606 | ||
1609 | current->flags &= ~PF_MEMALLOC; | 1607 | current->flags &= ~PF_MEMALLOC; |
1610 | 1608 | ||
@@ -1615,9 +1613,8 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) | |||
1615 | if (r) | 1613 | if (r) |
1616 | goto out; | 1614 | goto out; |
1617 | 1615 | ||
1618 | param_size = param->data_size; | ||
1619 | param->data_size = sizeof(*param); | 1616 | param->data_size = sizeof(*param); |
1620 | r = fn(param, param_size); | 1617 | r = fn(param, input_param_size); |
1621 | 1618 | ||
1622 | /* | 1619 | /* |
1623 | * Copy the results back to userland. | 1620 | * Copy the results back to userland. |
@@ -1625,8 +1622,8 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) | |||
1625 | if (!r && copy_to_user(user, param, param->data_size)) | 1622 | if (!r && copy_to_user(user, param, param->data_size)) |
1626 | r = -EFAULT; | 1623 | r = -EFAULT; |
1627 | 1624 | ||
1628 | out: | 1625 | out: |
1629 | free_params(param); | 1626 | vfree(param); |
1630 | return r; | 1627 | return r; |
1631 | } | 1628 | } |
1632 | 1629 | ||