diff mbox

[2/3] dm ioctl: tidy code for next change

Message ID 1296691696-23722-2-git-send-email-mbroz@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Milan Broz Feb. 3, 2011, 12:08 a.m. UTC
None
diff mbox

Patch

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, &param);
+	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;
 }