From: Tom Rix <trix@redhat.com>
To: sfrench@samba.org, nathan@kernel.org, ndesaulniers@google.com,
dhowells@redhat.com
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Tom Rix <trix@redhat.com>
Subject: [PATCH] cifs: set length when cifs_copy_pages_to_iter is successful
Date: Thu, 26 May 2022 10:02:26 -0400 [thread overview]
Message-ID: <20220526140226.2648689-1-trix@redhat.com> (raw)
clang build fails with
fs/cifs/smb2ops.c:4984:7: error: variable 'length' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (rdata->result != 0) {
^~~~~~~~~~~~~~~~~~
handle_read_data() returns the number of bytes handled by setting the length variable.
This only happens in the copy_to_iter() branch, it needs to also happen in the
cifs_copy_pages_to_iter() branch. When cifs_copy_pages_to_iter() is successful,
its parameter data_len is how many bytes were handled, so set length to data_len.
Fixes: 67fd8cff2b0f ("cifs: Change the I/O paths to use an iterator rather than a page list")
Signed-off-by: Tom Rix <trix@redhat.com>
---
fs/cifs/smb2ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 3630e132781f..bfad482ec186 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -4988,7 +4988,7 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid,
dequeue_mid(mid, rdata->result);
return 0;
}
- rdata->got_bytes = pages_len;
+ length = rdata->got_bytes = pages_len;
} else if (buf_len >= data_offset + data_len) {
/* read response payload is in buf */
--
2.27.0
next reply other threads:[~2022-05-26 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 14:02 Tom Rix [this message]
2022-05-27 19:32 ` [PATCH] cifs: set length when cifs_copy_pages_to_iter is successful Nick Desaulniers
2022-05-28 23:31 ` Steve French
2022-05-29 12:52 ` Tom Rix
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=20220526140226.2648689-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=dhowells@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
/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