linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Dan Carpenter <error27@gmail.com>
Cc: dchinner@redhat.com, linux-fsdevel@vger.kernel.org
Subject: Re: [bug report] iomap: write iomap validity checks
Date: Fri, 20 Jan 2023 16:16:55 +0000	[thread overview]
Message-ID: <Y8q+d7TIZiT9nRVa@casper.infradead.org> (raw)
In-Reply-To: <Y8qbWDfLGqUDnbsz@kili>

On Fri, Jan 20, 2023 at 04:47:04PM +0300, Dan Carpenter wrote:
> Hello Dave Chinner,
> 
> The patch d7b64041164c: "iomap: write iomap validity checks" from Nov
> 29, 2022, leads to the following Smatch static checker warning:
> 
> 	fs/iomap/buffered-io.c:829 iomap_write_iter()
> 	error: uninitialized symbol 'folio'.
> 
> fs/iomap/buffered-io.c
>     818                 if (unlikely(fault_in_iov_iter_readable(i, bytes) == bytes)) {
>     819                         status = -EFAULT;
>     820                         break;
>     821                 }
>     822 
>     823                 status = iomap_write_begin(iter, pos, bytes, &folio);
>                                                                      ^^^^^^^
> The iomap_write_begin() function can succeed without initializing
> *foliop.  It's next to the big comment.

Yes, but if it does, it sets IOMAP_F_STALE

>     824                 if (unlikely(status))
>     825                         break;
>     826                 if (iter->iomap.flags & IOMAP_F_STALE)
>     827                         break;

so it breaks out here.  Maybe we should return an errno from
iomap_write_begin() to make life easier for the static checking tools?

> --> 829                 page = folio_file_page(folio, pos >> PAGE_SHIFT);
>                                                ^^^^^
> 
>     830                 if (mapping_writably_mapped(mapping))
>     831                         flush_dcache_page(page);

  reply	other threads:[~2023-01-20 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 13:47 [bug report] iomap: write iomap validity checks Dan Carpenter
2023-01-20 16:16 ` Matthew Wilcox [this message]
2023-01-23  6:55   ` Dan Carpenter

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=Y8q+d7TIZiT9nRVa@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=dchinner@redhat.com \
    --cc=error27@gmail.com \
    --cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).