From: Al Viro Date: Sat, 2 Jan 2016 19:59:38 +0000 (-0500) Subject: cdrom: don't open-code memdup_user() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=abb0f6a79fe8eba7982b73313b8623259d78c3f6;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git cdrom: don't open-code memdup_user() Signed-off-by: Al Viro --- diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index c206ccda899b..1b257ea9776a 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3186,15 +3186,11 @@ static noinline int mmc_ioctl_dvd_read_struct(struct cdrom_device_info *cdi, if (!CDROM_CAN(CDC_DVD)) return -ENOSYS; - s = kmalloc(size, GFP_KERNEL); - if (!s) - return -ENOMEM; + s = memdup_user(arg, size); + if (IS_ERR(s)) + return PTR_ERR(s); cd_dbg(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n"); - if (copy_from_user(s, arg, size)) { - kfree(s); - return -EFAULT; - } ret = dvd_read_struct(cdi, s, cgc); if (ret)