linux/tools/testing/nvdimm/test
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
..
iomap.c memremap: remove support for external pgmap refcounts 2022-08-17 14:23:43 +02:00
Kbuild testing/nvdimm: Add test module for non-nfit platforms 2021-01-28 00:22:48 -08:00
ndtest.c nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe() 2025-10-19 16:21:38 +02:00
ndtest.h ndtest: Add papr health related flags 2021-01-28 00:22:49 -08:00
nfit.c tools/testing/nvdimm: Fix missing 'fallthrough' warning 2021-08-11 11:55:54 -07:00
nfit_test.h tools/testing/nvdimm: Replace zero-length array with flexible-array 2020-06-15 23:08:32 -05:00