diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2015-12-15 11:00:40 (GMT) |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-01-11 14:19:16 (GMT) |
commit | a5c82e5622d1b7f479c9a43873c2c5ac1f67765c (patch) | |
tree | 4e16aafa5bc17fd1200bea8bf97bc87a82ba2d7f /drivers/media/media-device.c | |
parent | 8a95079668bf35b265d3bb6381b8badb5bfa826a (diff) | |
download | linux-a5c82e5622d1b7f479c9a43873c2c5ac1f67765c.tar.xz |
[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 <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r-- | drivers/media/media-device.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b3e19c2..30e3354 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, |