Commit bf7af0ce authored by Al Viro's avatar Al Viro

esas2r: don't open-code memdup_user()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 1c87ea45
...@@ -1289,32 +1289,13 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg) ...@@ -1289,32 +1289,13 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
|| (cmd > EXPRESS_IOCTL_MAX)) || (cmd > EXPRESS_IOCTL_MAX))
return -ENOTSUPP; return -ENOTSUPP;
if (!access_ok(VERIFY_WRITE, arg, sizeof(struct atto_express_ioctl))) { ioctl = memdup_user(arg, sizeof(struct atto_express_ioctl));
if (IS_ERR(ioctl)) {
esas2r_log(ESAS2R_LOG_WARN, esas2r_log(ESAS2R_LOG_WARN,
"ioctl_handler access_ok failed for cmd %d, " "ioctl_handler access_ok failed for cmd %d, "
"address %p", cmd, "address %p", cmd,
arg); arg);
return -EFAULT; return PTR_ERR(ioctl);
}
/* allocate a kernel memory buffer for the IOCTL data */
ioctl = kzalloc(sizeof(struct atto_express_ioctl), GFP_KERNEL);
if (ioctl == NULL) {
esas2r_log(ESAS2R_LOG_WARN,
"ioctl_handler kzalloc failed for %zu bytes",
sizeof(struct atto_express_ioctl));
return -ENOMEM;
}
err = __copy_from_user(ioctl, arg, sizeof(struct atto_express_ioctl));
if (err != 0) {
esas2r_log(ESAS2R_LOG_WARN,
"copy_from_user didn't copy everything (err %d, cmd %d)",
err,
cmd);
kfree(ioctl);
return -EFAULT;
} }
/* verify the signature */ /* verify the signature */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment