Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: dhowells@redhat.com, linux-cifs@vger.kernel.org
Subject: Re: [bug report] cifs: Fix writeback data corruption
Date: Fri, 01 Mar 2024 17:25:16 +0000	[thread overview]
Message-ID: <450034.1709313916@warthog.procyon.org.uk> (raw)
In-Reply-To: <862d95d6-5aa5-4542-a22c-2be58fd5c733@moroto.mountain>

Dan Carpenter <dan.carpenter@linaro.org> wrote:

> 
> The patch 374ce0748c79: "cifs: Fix writeback data corruption" from
> Feb 22, 2024 (linux-next), leads to the following Smatch static
> checker warning:
> 
> 	fs/smb/client/file.c:2869 cifs_write_back_from_locked_folio()
> 	error: uninitialized symbol 'len'.

Good catch.  len should be the length of the start folio we're given:

--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2749,7 +2749,7 @@ static ssize_t cifs_write_back_from_locked_folio(struct address_space *mapping,
 	struct cifsFileInfo *cfile = NULL;
 	unsigned long long i_size = i_size_read(inode), max_len;
 	unsigned int xid, wsize;
-	size_t len;
+	size_t len = folio_size(folio);
 	long count = wbc->nr_to_write;
 	int rc;
 
@@ -2793,7 +2793,6 @@ static ssize_t cifs_write_back_from_locked_folio(struct address_space *mapping,
 	 * immediately lockable, is not dirty or is missing, or we reach the
 	 * end of the range.
 	 */
-	len = folio_size(folio);
 	if (start < i_size) {
 		/* Trim the write to the EOF; the extra data is ignored.  Also
 		 * put an upper limit on the size of a single storedata op.

David


  reply	other threads:[~2024-03-01 17:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 10:52 [bug report] cifs: Fix writeback data corruption Dan Carpenter
2024-03-01 17:25 ` David Howells [this message]
2024-03-06 16:06   ` Steve French

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=450034.1709313916@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-cifs@vger.kernel.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