Re: [PATCH] btrfs: tests: zoned: fix NULL check of the active bitmap
From: Naohiro Aota
Date: Tue Nov 17 2026 - 00:01:08 EST
On Tue Nov 17, 2026 at 12:51 PM JST, Yifan Feng wrote:
> test_load_zone_info() allocates the active bitmap with bitmap_zalloc()
> but then tests zone_info, which was already checked a few lines above.
> A failed allocation is not detected, and the NULL bitmap is then used
> by __set_bit() and by btrfs_load_block_group_by_raid_type().
>
> Check the active bitmap instead.
>
> Tested in QEMU with the bitmap size temporarily changed to UINT_MAX so
> that the allocation fails. Without this patch the kernel oopses in
> btrfs_test_zoned() with a NULL pointer dereference. With it the test
> prints "cannot allocate active bitmap" and fails cleanly.
>
> Found by searching for a NULL check that tests a different pointer than
> the one just allocated, with the help of an AI coding assistant
> (Claude).
>
> Fixes: 1ba19a6ea9f2 ("btrfs: tests: zoned: add tests cases for zoned code")
> Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
Reviewed-by: Naohiro Aota <naohiro.aota@xxxxxxx>