From: Dan Carpenter <dan.carpenter@oracle.com>
To: willy@infradead.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [bug report] mpage: Convert do_mpage_readpage() to use a folio
Date: Wed, 22 Jun 2022 09:56:20 +0300 [thread overview]
Message-ID: <YrK9FMnNO3yCmGpk@kili> (raw)
Hello Matthew Wilcox (Oracle),
The patch 4c27dc762d7b: "mpage: Convert do_mpage_readpage() to use a
folio" from Jun 10, 2022, leads to the following Smatch static
checker warning:
fs/mpage.c:102 map_buffer_to_folio()
error: we previously assumed 'page_bh' could be null (see line 99)
fs/mpage.c
78 static void map_buffer_to_folio(struct folio *folio, struct buffer_head *bh,
79 int page_block)
80 {
81 struct inode *inode = folio->mapping->host;
82 struct buffer_head *page_bh, *head;
83 int block = 0;
84
85 head = folio_buffers(folio);
86 if (!head) {
87 /*
88 * don't make any buffers if there is only one buffer on
89 * the folio and the folio just needs to be set up to date
90 */
91 if (inode->i_blkbits == PAGE_SHIFT &&
92 buffer_uptodate(bh)) {
93 folio_mark_uptodate(folio);
94 return;
95 }
96 create_empty_buffers(&folio->page, i_blocksize(inode), 0);
97 }
Originally there was a "head = page_buffers(page);" here but now head
is left as NULL.
98
99 page_bh = head;
100 do {
101 if (block == page_block) {
--> 102 page_bh->b_state = bh->b_state;
103 page_bh->b_bdev = bh->b_bdev;
104 page_bh->b_blocknr = bh->b_blocknr;
105 break;
106 }
107 page_bh = page_bh->b_this_page;
^^^^^^^^^
Which will crash.
108 block++;
109 } while (page_bh != head);
110 }
regards,
dan carpenter
reply other threads:[~2022-06-22 6:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=YrK9FMnNO3yCmGpk@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=willy@infradead.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