public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: dvb_ringbuffer: Return -EFAULT if copy fails
@ 2023-05-24  1:27 Su Hui
  2023-05-24  4:23 ` Dan Carpenter
  0 siblings, 1 reply; 9+ messages in thread
From: Su Hui @ 2023-05-24  1:27 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: YongSu Yoo, linux-media, linux-kernel, kernel-janitors, Su Hui

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-29  1:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24  1:27 [PATCH] media: dvb_ringbuffer: Return -EFAULT if copy fails Su Hui
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox