Skip to content

lib/genalloc: fix a NULL pool check and add KUnit tests

Amit Patole linux-kselftest lkml 1 version In review

Get series with b4
b4 am [email protected] change-id 20261106-kunit-genalloc-32ccb20f97a6

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2lib/genalloc: don't dereference a NULL pool in gen_pool_dma_[z]alloc()lib/genalloc.c+6 -01 reply
2/2lib/tests: add KUnit tests for genalloclib/Kconfig.debug lib/tests/Makefile lib/tests/genalloc_kunit.c+524 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] lib/genalloc: fix a NULL pool check and add KUnit tests

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,

Signature · 1 line
Amit Patole <[email protected]>