* [bug report] mpage: Convert do_mpage_readpage() to use a folio
@ 2022-06-22 6:56 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-06-22 6:56 UTC (permalink / raw)
To: willy; +Cc: linux-fsdevel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-22 6:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-22 6:56 [bug report] mpage: Convert do_mpage_readpage() to use a folio Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox