Re: [PATCH RESEND] ext4: Fix potential NULL pointer dereferences in test_mb_mark_used() and test_mb_free_blocks()

From: Theodore Ts'o
Date: Fri Mar 21 2025 - 01:05:23 EST


On Thu, Mar 13, 2025 at 12:00:21AM +0000, Qasim Ijaz wrote:
> test_mb_mark_used() and test_mb_free_blocks() call kunit_kzalloc() to
> allocate memory, however both fail to ensure that the allocations
> succeeded. If kunit_kzalloc() returns NULL, then dereferencing the
> corresponding pointer without checking for NULL will lead to
> a NULL pointer dereference.
>
> To fix this call KUNIT_ASSERT_NOT_ERR_OR_NULL() to ensure
> the allocation succeeded.

Thanks; other folks have sent this fix.

- Ted