kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] [media] media-device: copy_to/from_user() returns positive
Date: Tue, 15 Dec 2015 11:00:40 +0000	[thread overview]
Message-ID: <20151215110040.GA9594@mwanda> (raw)

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,

                 reply	other threads:[~2015-12-15 11:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151215110040.GA9594@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).