linux/tools/testing
Guangshuo Li 972cbba5cd 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-19 16:21:38 +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:24:20 +02:00
kunit kunit: tool: Import missing importlib.abc 2022-02-23 12:03:04 +01:00
nvdimm nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe() 2025-10-19 16:21:38 +02:00
radix-tree radix tree test suite: fix incorrect allocation size for pthreads 2023-08-16 18:21:58 +02:00
scatterlist Merge branch 'akpm' (patches from Andrew) 2021-09-03 10:08:28 -07:00
selftests selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported 2025-10-19 16:21:31 +02:00
vsock vsock_diag_test: remove free_sock_stat() call in test_no_sockets 2021-10-15 17:21:34 -07:00