From: Dan Carpenter Date: Tue, 15 Dec 2015 11:00:40 +0000 (-0200) Subject: [media] media-device: copy_to/from_user() returns positive X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a5c82e5622d1b7f479c9a43873c2c5ac1f67765c;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [media] media-device: copy_to/from_user() returns positive The copy_to/from_user() functions return the number of bytes *not* copied. They don't return error codes. Fixes: 4f6b3f363475 ('media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl') Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b3e19c22e699..30e3354d7481 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -376,18 +376,17 @@ static long media_device_get_topology(struct media_device *mdev, struct media_v2_topology ktopo; int ret; - ret = copy_from_user(&ktopo, utopo, sizeof(ktopo)); - - if (ret < 0) - return ret; + if (copy_from_user(&ktopo, utopo, sizeof(ktopo))) + return -EFAULT; ret = __media_device_get_topology(mdev, &ktopo); if (ret < 0) return ret; - ret = copy_to_user(utopo, &ktopo, sizeof(*utopo)); + if (copy_to_user(utopo, &ktopo, sizeof(*utopo))) + return -EFAULT; - return ret; + return 0; } static long media_device_ioctl(struct file *filp, unsigned int cmd,