From: Su Hui <suhui@nfschina.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: YongSu Yoo <yongsuyoo0215@gmail.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, Su Hui <suhui@nfschina.com>
Subject: [PATCH] media: dvb_ringbuffer: Return -EFAULT if copy fails
Date: Wed, 24 May 2023 09:27:33 +0800 [thread overview]
Message-ID: <20230524012733.414441-1-suhui@nfschina.com> (raw)
The copy_to/from_user() functions return the number of bytes remaining
to be copied, but we want to return -EFAULT to the user.
Fixes: 04da2daee383 ("[media] ngene: properly handle __user ptr")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
drivers/media/dvb-core/dvb_ringbuffer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c
index 7d4558de8e83..f132578840ad 100644
--- a/drivers/media/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb-core/dvb_ringbuffer.c
@@ -216,7 +216,7 @@ ssize_t dvb_ringbuffer_write_user(struct dvb_ringbuffer *rbuf,
if (split > 0) {
status = copy_from_user(rbuf->data+rbuf->pwrite, buf, split);
if (status)
- return len - todo;
+ return -EFAULT;
buf += split;
todo -= split;
/* smp_store_release() for write pointer update to ensure that
@@ -228,7 +228,7 @@ ssize_t dvb_ringbuffer_write_user(struct dvb_ringbuffer *rbuf,
}
status = copy_from_user(rbuf->data+rbuf->pwrite, buf, todo);
if (status)
- return len - todo;
+ return -EFAULT;
/* smp_store_release() for write pointer update, see above */
smp_store_release(&rbuf->pwrite, (rbuf->pwrite + todo) % rbuf->size);
--
2.30.2
next reply other threads:[~2023-05-24 1:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 1:27 Su Hui [this message]
2023-05-24 4:23 ` Dan Carpenter
2023-05-24 4:47 ` Dan Carpenter
2023-05-24 5:20 ` Su Hui
2023-05-24 7:20 ` Dan Carpenter
2023-05-24 8:23 ` Longsuhui
2023-05-26 10:45 ` Mauro Carvalho Chehab
2023-05-29 1:08 ` Longsuhui
2023-05-29 1:54 ` Su Hui
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=20230524012733.414441-1-suhui@nfschina.com \
--to=suhui@nfschina.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=yongsuyoo0215@gmail.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
all inboxes | Powered by JetHome®