buffer: allow a buffer_head to point at memory outside the page cache
Hello Chao Shi,
Commit 8deae2284976 ("buffer: allow a buffer_head to point at memory outside the page cache") from Aug 6, 2026, leads to the following Smatch complaint:
fs/buffer.c:1118 __bh_submit()
warn: variable dereferenced before check 'bh->b_folio' (see line 1109)fs/buffer.c
1108
1109 if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
^^^^^^^^^^^
Dereferenced here.
1110 bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
1111
1112 if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
1113 buffer_set_crypto_ctx(bio, bh, GFP_NOIO);
1114
1115 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
1116 bio->bi_write_hint = write_hint;
1117
1118 if (bh->b_folio)
1119 bio_add_folio_nofail(bio, bh->b_folio, bh->b_size,
1120 bh_offset(bh));
1121 else
1122 bio_add_virt_nofail(bio, bh->b_data, bh->b_size);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This is dead code.
1123 1124 bio->bi_end_io = end_bio; 1125 bio->bi_private = bh;
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter