linux/tools/testing
Guangshuo Li bc8b56317f nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe()
commit a9e6aa9949 upstream.

devm_kcalloc() may fail. ndtest_probe() allocates three DMA address
arrays (dcr_dma, label_dma, dimm_dma) and later unconditionally uses
them in ndtest_nvdimm_init(), which can lead to a NULL pointer
dereference under low-memory conditions.

Check all three allocations and return -ENOMEM if any allocation fails,
jumping to the common error path. Do not emit an extra error message
since the allocator already warns on allocation failure.

Fixes: 9399ab61ad ("ndtest: Add dimms to the two buses")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-15 11:56:40 +02:00
..
crypto/chacha20-s390 tools/testing/crypto: Use vzalloc instead of vmalloc+memset 2022-07-05 14:46:36 +02:00
cxl cxl/test: Add missing vmalloc.h for tools/testing/cxl/test/mem.c 2024-06-21 14:35:45 +02:00
fault-injection docs: fault-injection: convert docs to ReST and rename to *.rst 2019-06-14 14:21:07 -06:00
ktest ktest.pl: Prevent recursion of default variable options 2025-08-28 16:25:55 +02:00
kunit kunit: tool: Use qboot on QEMU x86_64 2025-06-04 14:40:14 +02:00
memblock memblock tests: fix warning ‘struct seq_file’ declared inside parameter list 2023-10-06 14:56:56 +02:00
nvdimm nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe() 2025-10-15 11:56:40 +02:00
radix-tree test suite: use %zu to print size_t 2025-04-25 10:43:50 +02:00
scatterlist tools/testing/scatterlist: add missing defines 2022-01-30 09:56:58 +02:00
selftests selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported 2025-10-15 11:56:28 +02:00
vsock vsock_test: POLLIN + SO_RCVLOWAT test 2022-08-23 10:43:12 +02:00