* [PATCH] cifs: Fix copy_to_iter return value check
@ 2025-10-05 6:49 Fushuai Wang
2025-10-05 10:45 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Fushuai Wang @ 2025-10-05 6:49 UTC (permalink / raw)
To: sfrench, pc, ronniesahlberg, sprasad, tom, bharathsm
Cc: linux-cifs, samba-technical, linux-kernel, Fushuai Wang
The return value of copy_to_iter() function will never be negative,
it is the number of bytes copied, or zero if nothing was copied.
Update the check to treat length <= 0 as an error, and return -1
in that case.
Fixes: d08089f649a0 ("cifs: Change the I/O paths to use an iterator rather than a page list")
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
fs/smb/client/smb2ops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 058050f744c0..2383a80b9ed1 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -4764,8 +4764,8 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
/* read response payload is in buf */
WARN_ONCE(buffer, "read data can be either in buf or in buffer");
length = copy_to_iter(buf + data_offset, data_len, &rdata->subreq.io_iter);
- if (length < 0)
- return length;
+ if (length <= 0)
+ return -1;
rdata->got_bytes = data_len;
} else {
/* read response payload cannot be in both buf and pages */
--
2.36.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] cifs: Fix copy_to_iter return value check
2025-10-05 6:49 [PATCH] cifs: Fix copy_to_iter return value check Fushuai Wang
@ 2025-10-05 10:45 ` Markus Elfring
2025-10-05 13:51 ` Fushuai Wang
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2025-10-05 10:45 UTC (permalink / raw)
To: Fushuai Wang, linux-cifs, samba-technical, Bharath SM,
Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Steve French,
Tom Talpey
Cc: LKML
> The return value of copy_to_iter() function will never be negative,
> it is the number of bytes copied, or zero if nothing was copied.
…
Why do you propose to preserve the comparison operator part “<” then?
Would the condition check “!length” be nicer at this place?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cifs: Fix copy_to_iter return value check
2025-10-05 10:45 ` Markus Elfring
@ 2025-10-05 13:51 ` Fushuai Wang
0 siblings, 0 replies; 3+ messages in thread
From: Fushuai Wang @ 2025-10-05 13:51 UTC (permalink / raw)
To: markus.elfring
Cc: bharathsm, linux-cifs, linux-kernel, pc, ronniesahlberg,
samba-technical, sfrench, sprasad, tom, wangfushuai
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 353 bytes --]
>> The return value of copy_to_iter() function will never be negative,
>> it is the number of bytes copied, or zero if nothing was copied.
> …
>
> Why do you propose to preserve the comparison operator part “<” then?
> Would the condition check “!length” be nicer at this place?
Yes, you are right. I will send a v2 shortly.
Regards,
Wang.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-05 13:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-05 6:49 [PATCH] cifs: Fix copy_to_iter return value check Fushuai Wang
2025-10-05 10:45 ` Markus Elfring
2025-10-05 13:51 ` Fushuai Wang
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®