public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/mock: Modify the return value check
@ 2025-09-10  9:03 zhangjiao2
  0 siblings, 0 replies; only message in thread
From: zhangjiao2 @ 2025-09-10  9:03 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, linux-kernel, zhang jiao

From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

The return value of copy_from_iter and copy_to_iter can't be negative,
check whether the copied lengths are equal.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 io_uring/mock_file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/io_uring/mock_file.c b/io_uring/mock_file.c
index 45d3735b2708..bdbb1bd8e2c8 100644
--- a/io_uring/mock_file.c
+++ b/io_uring/mock_file.c
@@ -42,7 +42,7 @@ static int io_copy_regbuf(struct iov_iter *reg_iter, void __user *ubuf)
 
 		if (iov_iter_rw(reg_iter) == ITER_SOURCE) {
 			ret = copy_from_iter(tmp_buf, len, reg_iter);
-			if (ret <= 0)
+			if (ret != len)
 				break;
 			if (copy_to_user(ubuf, tmp_buf, ret))
 				break;
@@ -50,7 +50,7 @@ static int io_copy_regbuf(struct iov_iter *reg_iter, void __user *ubuf)
 			if (copy_from_user(tmp_buf, ubuf, len))
 				break;
 			ret = copy_to_iter(tmp_buf, len, reg_iter);
-			if (ret <= 0)
+			if (ret != len)
 				break;
 		}
 		ubuf += ret;
-- 
2.33.0




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-10  9:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10  9:03 [PATCH] io_uring/mock: Modify the return value check zhangjiao2

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