]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe()
authorGuangshuo Li <lgs201920130244@gmail.com>
Thu, 25 Sep 2025 06:44:48 +0000 (14:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:40 +0000 (11:56 +0200)
commitbc8b56317ff83ef4bba89bda356b93978604694f
tree1c5417d93b95ba27d5e7a26370b2fd2e83e9b6e5
parent957faf9582f92bb2be8ebe4ab6aa1c2bc71d9859
nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe()

commit a9e6aa994917ee602798bbb03180a194b37865bb 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: 9399ab61ad82 ("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>
tools/testing/nvdimm/test/ndtest.c