From: Santosh Sivaraj <santosh@fossix.org>
To: Linux NVDIMM <nvdimm@lists.linux.dev>
Cc: Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Shivaprasad G Bhat <sbhat@linux.ibm.com>,
Santosh Sivaraj <santosh@fossix.org>
Subject: [PATCH] nvdimm/test: Fix corruption due to memory overflow
Date: Fri, 4 Jun 2021 12:38:28 +0530 [thread overview]
Message-ID: <20210604070828.2747433-1-santosh@fossix.org> (raw)
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
reply other threads:[~2021-06-04 7:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210604070828.2747433-1-santosh@fossix.org \
--to=santosh@fossix.org \
--cc=dan.j.williams@intel.com \
--cc=nvdimm@lists.linux.dev \
--cc=sbhat@linux.ibm.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).