kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] [media] media-device: copy_to/from_user() returns positive
@ 2015-12-15 11:00 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-12-15 11:00 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, kernel-janitors

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>

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index c12481c..96ed207 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,

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-15 11:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 11:00 [patch] [media] media-device: copy_to/from_user() returns positive Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).