nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvdimm/test: Fix corruption due to memory overflow
@ 2021-06-04  7:08 Santosh Sivaraj
  0 siblings, 0 replies; only message in thread
From: Santosh Sivaraj @ 2021-06-04  7:08 UTC (permalink / raw)
  To: Linux NVDIMM
  Cc: Dan Williams, Vishal Verma, Shivaprasad G Bhat, Santosh Sivaraj

The test allocates memory only for 4 DIMMS but more dimms are
configured, due to which the module crashes on exit, strangely
this was not observed on x86 so far, but very easily reproduced on
PowerPC.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 tools/testing/nvdimm/test/ndtest.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c
index 09d98317bf4e..960a37aa3f07 100644
--- a/tools/testing/nvdimm/test/ndtest.c
+++ b/tools/testing/nvdimm/test/ndtest.c
@@ -22,7 +22,6 @@ enum {
 	DIMM_SIZE = SZ_32M,
 	LABEL_SIZE = SZ_128K,
 	NUM_INSTANCES = 2,
-	NUM_DCR = 4,
 	NDTEST_MAX_MAPPING = 6,
 };
 
@@ -1606,8 +1605,6 @@ static const struct attribute_group *ndtest_attribute_groups[] = {
 
 static int ndtest_bus_register(struct ndtest_priv *p)
 {
-	p->config = &bus_configs[p->pdev.id];
-
 	p->bus_desc.ndctl = ndtest_ctl;
 	p->bus_desc.module = THIS_MODULE;
 	p->bus_desc.provider_name = NULL;
@@ -1667,14 +1664,16 @@ static int ndtest_probe(struct platform_device *pdev)
 	int rc;
 
 	p = to_ndtest_priv(&pdev->dev);
+	p->config = &bus_configs[pdev->id];
+
 	if (ndtest_bus_register(p))
 		return -ENOMEM;
 
-	p->dcr_dma = devm_kcalloc(&p->pdev.dev, NUM_DCR,
+	p->dcr_dma = devm_kcalloc(&p->pdev.dev, p->config->dimm_count,
 				 sizeof(dma_addr_t), GFP_KERNEL);
-	p->label_dma = devm_kcalloc(&p->pdev.dev, NUM_DCR,
+	p->label_dma = devm_kcalloc(&p->pdev.dev, p->config->dimm_count,
 				   sizeof(dma_addr_t), GFP_KERNEL);
-	p->dimm_dma = devm_kcalloc(&p->pdev.dev, NUM_DCR,
+	p->dimm_dma = devm_kcalloc(&p->pdev.dev, p->config->dimm_count,
 				  sizeof(dma_addr_t), GFP_KERNEL);
 
 	rc = ndtest_nvdimm_init(p);
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-04  7:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04  7:08 [PATCH] nvdimm/test: Fix corruption due to memory overflow Santosh Sivaraj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).