From: Dan Carpenter <error27@gmail.com>
To: walter harms <wharms@bfs.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch v2] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user
Date: Fri, 04 Jun 2010 15:39:03 +0000 [thread overview]
Message-ID: <20100604153903.GH5483@bicker> (raw)
In-Reply-To: <4C08F0DD.50702@bfs.de>
copy_to_user() returns the number of bytes remaining to be copied which
isn't the right thing to return here. The comments say that these
functions in dvb_ca_en50221.c should return the number of bytes copied or
an error return. I've changed it to return -EFAULT.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
V2: Some style fixes suggested by Walter Harms.
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index ef259a0..cb97e6b 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1318,8 +1318,11 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
fragbuf[0] = connection_id;
fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
- if ((status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen)) != 0)
+ status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen);
+ if (status) {
+ status = -EFAULT;
goto exit;
+ }
timeout = jiffies + HZ / 2;
written = 0;
@@ -1494,8 +1497,11 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
hdr[0] = slot;
hdr[1] = connection_id;
- if ((status = copy_to_user(buf, hdr, 2)) != 0)
+ status = copy_to_user(buf, hdr, 2);
+ if (status) {
+ status = -EFAULT;
goto exit;
+ }
status = pktlen;
exit:
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: walter harms <wharms@bfs.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch v2] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user errors
Date: Fri, 4 Jun 2010 17:39:03 +0200 [thread overview]
Message-ID: <20100604153903.GH5483@bicker> (raw)
In-Reply-To: <4C08F0DD.50702@bfs.de>
copy_to_user() returns the number of bytes remaining to be copied which
isn't the right thing to return here. The comments say that these
functions in dvb_ca_en50221.c should return the number of bytes copied or
an error return. I've changed it to return -EFAULT.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
V2: Some style fixes suggested by Walter Harms.
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index ef259a0..cb97e6b 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1318,8 +1318,11 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
fragbuf[0] = connection_id;
fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
- if ((status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen)) != 0)
+ status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen);
+ if (status) {
+ status = -EFAULT;
goto exit;
+ }
timeout = jiffies + HZ / 2;
written = 0;
@@ -1494,8 +1497,11 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
hdr[0] = slot;
hdr[1] = connection_id;
- if ((status = copy_to_user(buf, hdr, 2)) != 0)
+ status = copy_to_user(buf, hdr, 2);
+ if (status) {
+ status = -EFAULT;
goto exit;
+ }
status = pktlen;
exit:
next prev parent reply other threads:[~2010-06-04 15:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-04 10:36 [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user Dan Carpenter
2010-06-04 10:36 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user errors Dan Carpenter
2010-06-04 12:26 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user walter harms
2010-06-04 12:26 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user errors walter harms
2010-06-04 15:37 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on Dan Carpenter
2010-06-04 15:37 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user errors Dan Carpenter
2010-06-04 15:39 ` Dan Carpenter [this message]
2010-06-04 15:39 ` [patch v2] " Dan Carpenter
2010-06-04 17:14 ` [patch] V4L/DVB: dvb_ca_en50221: return -EFAULT on copy_to_user walter harms
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=20100604153903.GH5483@bicker \
--to=error27@gmail.com \
--cc=arnd@arndb.de \
--cc=fweisbec@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=wharms@bfs.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.