From: Milan Broz <mbroz@redhat.com>
To: dm-devel@redhat.com
Cc: Milan Broz <mbroz@redhat.com>
Subject: [PATCH 2/3] dm ioctl: tidy code for next change
Date: Thu, 3 Feb 2011 01:08:15 +0100 [thread overview]
Message-ID: <1296691696-23722-2-git-send-email-mbroz@redhat.com> (raw)
In-Reply-To: <1296691696-23722-1-git-send-email-mbroz@redhat.com>
Prepare code for implementing buffer wipe flag.
No functional change in this patch.
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
drivers/md/dm-ioctl.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 6d12775..189c7ab 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)
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;
@@ -1520,13 +1515,14 @@ 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 fail;
*param = dmi;
return 0;
+fail:
+ vfree(dmi);
+ return -EFAULT;
}
static int validate_params(uint cmd, struct dm_ioctl *param)
@@ -1605,6 +1601,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
* Copy the parameters into kernel space.
*/
r = copy_params(user, ¶m);
+ param_size = param->data_size;
current->flags &= ~PF_MEMALLOC;
@@ -1615,7 +1612,6 @@ 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);
@@ -1624,9 +1620,8 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
*/
if (!r && copy_to_user(user, param, param->data_size))
r = -EFAULT;
-
- out:
- free_params(param);
+out:
+ vfree(param);
return r;
}
--
1.7.2.3
next prev parent reply other threads:[~2011-02-03 0:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-03 0:08 [PATCH 1/3] dm crypt: wipe keys string immediately after key is set Milan Broz
2011-02-03 0:08 ` Milan Broz [this message]
2011-02-03 15:39 ` [PATCH 2/3] dm ioctl: tidy code for next change Mike Snitzer
2011-02-03 0:08 ` [PATCH 3/3] dm ioctl: add data secure (bufer wipe) flag Milan Broz
2011-02-03 15:48 ` Mike Snitzer
2011-02-03 15:52 ` [PATCH 1/3] dm crypt: wipe keys string immediately after key is set Mike Snitzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296691696-23722-2-git-send-email-mbroz@redhat.com \
--to=mbroz@redhat.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox