mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Talpey <tom@talpey.com>
To: Steve French <smfrench@gmail.com>
Cc: Fushuai Wang <wangfushuai@baidu.com>,
	David Howells <dhowells@redhat.com>,
	pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, bharathsm@microsoft.com,
	Markus.Elfring@web.de, linux-cifs@vger.kernel.org,
	samba-technical@lists.samba.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] cifs: Fix copy_to_iter return value check
Date: Tue, 7 Oct 2025 15:03:27 -0400 (EDT)	[thread overview]
Message-ID: <a22c8ce5-da8f-42d9-a02e-5cfe048b514b@talpey.com> (raw)
In-Reply-To: <CAH2r5mvws19ho44YJDROdNUy3FtWfxyVE8QcbCTbFJ_VWYNQ9Q@mail.gmail.com>

I like it. For v5 feel free to add my Reviewed-by and ack.

Tom.

Oct 7, 2025 2:45:33 PM Steve French <smfrench@gmail.com>:

> David suggested fixing this line:
> 
> +                       return -1;
> 
> to
> 
> +                       return -EIO;
> 
> which makes sense to me since returning -1 could be confusing.
> 
> On Tue, Oct 7, 2025 at 3:27 AM Fushuai Wang <wangfushuai@baidu.com> wrote:
>> 
>> 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 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>
>> ---
>> v5: no code changes, only improve commit format
>> v4: no code changes, only add version description
>> v3: use size_t type for (copied) and check for (copied == 0) as error.
>> v2: use (!length) check for error condition.
>> v1: use (length <= 0) check for error condition.
>> 
>> fs/smb/client/smb2ops.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
>> index 058050f744c0..ac8a5bd6aec4 100644
>> --- a/fs/smb/client/smb2ops.c
>> +++ b/fs/smb/client/smb2ops.c
>> @@ -4650,7 +4650,7 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
>>         unsigned int pad_len;
>>         struct cifs_io_subrequest *rdata = mid->callback_data;
>>         struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
>> -       int length;
>> +       size_t copied;
>>         bool use_rdma_mr = false;
>> 
>>         if (shdr->Command != SMB2_READ) {
>> @@ -4763,10 +4763,10 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
>>         } else if (buf_len >= data_offset + data_len) {
>>                 /* 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;
>> -               rdata->got_bytes = data_len;
>> +               copied = copy_to_iter(buf + data_offset, data_len, &rdata->subreq.io_iter);
>> +               if (copied == 0)
>> +                       return -1;
>> +               rdata->got_bytes = copied;
>>         } else {
>>                 /* read response payload cannot be in both buf and pages */
>>                 WARN_ONCE(1, "buf can not contain only a part of read data");
> 
>> -- 
>> 2.36.1
>> 
>> 
> 
> 
> -- 
> Thanks,
> 
> Steve

      reply	other threads:[~2025-10-07 19:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  8:26 Fushuai Wang
2025-10-07 18:41 ` Steve French
2025-10-07 19:03   ` Tom Talpey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a22c8ce5-da8f-42d9-a02e-5cfe048b514b@talpey.com \
    --to=tom@talpey.com \
    --cc=Markus.Elfring@web.de \
    --cc=bharathsm@microsoft.com \
    --cc=dhowells@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=wangfushuai@baidu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome