Re: [PATCH 6.1] ext4: honor NULL returns from __filemap_get_folio()
From: Naman Jain
Date: Mon Nov 02 2026 - 15:03:55 EST
On 11/2/2026 10:39 PM, Matthew Wilcox wrote:
On Mon, Nov 02, 2026 at 04:33:41PM +0000, Naman Jain wrote:
The bitmap and buddy folio conversions assume that
__filemap_get_folio() returns error pointers. In Linux 6.1, however,
it returns NULL both when a non-creating lookup misses and when folio
creation fails.
A cache miss therefore passes the IS_ERR() check and reaches
folio_test_uptodate(NULL) in ext4_mb_load_buddy_gfp(). Creating-lookup
failures can also dereference NULL in its slow paths and in
ext4_mb_get_buddy_page_lock().
Restore NULL checks at all six lookup sites and return -ENOMEM when a
creating lookup fails. Preserve the folio locking and migration checks
without changing the global filemap API.
Fixes: d34e4fd4e73f ("ext4: convert bd_bitmap_page to bd_bitmap_folio")
Fixes: 862483175d3d ("ext4: convert bd_buddy_page to bd_buddy_folio")
Cc: stable@xxxxxxxxxxxxxxx # 6.1.x
Signed-off-by: Naman Jain <namjain@xxxxxxxxxxxxxxxxxxx>
Elliot beat you to it:
https://lore.kernel.org/linux-ext4/20261102-ext4-ntfs3-null-folio-v1-0-4fd91ee23a4a@xxxxxxxxxxxx/
Care to drop a R-b on his series?
Done.
I actually checked LKML in the morning for this :)
Regards,
Naman