[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230524012733.414441-1-suhui@nfschina.com>
Date: Wed, 24 May 2023 09:27:33 +0800
From: Su Hui <suhui@...china.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: YongSu Yoo <yongsuyoo0215@...il.com>, linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Su Hui <suhui@...china.com>
Subject: [PATCH] media: dvb_ringbuffer: Return -EFAULT if copy fails
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@...china.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
Powered by blists - more mailing lists