aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-03-30 12:27:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-04-06 02:11:00 -0400
commitbf7af0cea8a7980269ee1762f336cccb7b7e813e (patch)
treedb72ce6797cc886474a9bc7440a880e2b54ce9f3
parent1c87ea4566612ef37e31f6389cbb232bd49cdd45 (diff)
esas2r: don't open-code memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/scsi/esas2r/esas2r_ioctl.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index b35ed3829421..2d4b7f049a68 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -1289,32 +1289,13 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
1289 || (cmd > EXPRESS_IOCTL_MAX)) 1289 || (cmd > EXPRESS_IOCTL_MAX))
1290 return -ENOTSUPP; 1290 return -ENOTSUPP;
1291 1291
1292 if (!access_ok(VERIFY_WRITE, arg, sizeof(struct atto_express_ioctl))) { 1292 ioctl = memdup_user(arg, sizeof(struct atto_express_ioctl));
1293 if (IS_ERR(ioctl)) {
1293 esas2r_log(ESAS2R_LOG_WARN, 1294 esas2r_log(ESAS2R_LOG_WARN,
1294 "ioctl_handler access_ok failed for cmd %d, " 1295 "ioctl_handler access_ok failed for cmd %d, "
1295 "address %p", cmd, 1296 "address %p", cmd,
1296 arg); 1297 arg);
1297 return -EFAULT; 1298 return PTR_ERR(ioctl);
1298 }
1299
1300 /* allocate a kernel memory buffer for the IOCTL data */
1301 ioctl = kzalloc(sizeof(struct atto_express_ioctl), GFP_KERNEL);
1302 if (ioctl == NULL) {
1303 esas2r_log(ESAS2R_LOG_WARN,
1304 "ioctl_handler kzalloc failed for %zu bytes",
1305 sizeof(struct atto_express_ioctl));
1306 return -ENOMEM;
1307 }
1308
1309 err = __copy_from_user(ioctl, arg, sizeof(struct atto_express_ioctl));
1310 if (err != 0) {
1311 esas2r_log(ESAS2R_LOG_WARN,
1312 "copy_from_user didn't copy everything (err %d, cmd %d)",
1313 err,
1314 cmd);
1315 kfree(ioctl);
1316
1317 return -EFAULT;
1318 } 1299 }
1319 1300
1320 /* verify the signature */ 1301 /* verify the signature */