cifs: Fix copy_to_iter return value check
Subsystems (2)
PATCH 1/1 cifs: Fix copy_to_iter return value check
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.
--- fs/smb/client/smb2ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +2 -2
@@ -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 */
Signature · 1 line
2.36.1
Quoted 2 lines
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
Quoted 6 lines
Quoted 2 lines
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.