[PATCH 0/2] lib/genalloc: fix a NULL pool check and add KUnit tests
From: Amit Patole
Date: Fri Nov 06 2026 - 09:08:12 EST
genalloc has no unit tests, so patch 2 adds a KUnit suite. Writing it
turned up that gen_pool_dma_alloc() and gen_pool_dma_zalloc() crash on
a NULL pool, while the other DMA helpers return NULL as
gen_pool_dma_alloc() originally did. Patch 1 restores the check; no
in-tree caller passes a NULL pool, so it is not marked for stable.
Tested on UML with a kunitconfig of CONFIG_KUNIT=y and
CONFIG_GENALLOC_KUNIT_TEST=y: 12/12 pass with patch 1, and
genalloc_dma_test crashes without it.
---
Amit Patole (2):
lib/genalloc: don't dereference a NULL pool in gen_pool_dma_[z]alloc()
lib/tests: add KUnit tests for genalloc
lib/Kconfig.debug | 15 ++
lib/genalloc.c | 6 +
lib/tests/Makefile | 1 +
lib/tests/genalloc_kunit.c | 508 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 530 insertions(+)
---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261106-kunit-genalloc-32ccb20f97a6
Best regards,
--
Amit Patole <amit.patole@xxxxxxxxx>