Skip to content

Commit 6a84fb4

Browse files
committed
device-dax: check devm_nsio_enable() return value
If the dax_pmem driver is passed a resource that is already busy the driver probe attempt should fail with a message like the following: dax_pmem dax0.1: could not reserve region [mem 0x100000000-0x11fffffff] However, if we do not catch the error we crash for the obvious reason of accessing memory that is not mapped. BUG: unable to handle kernel paging request at ffffc90020001000 IP: [<ffffffff81496712>] __memcpy+0x12/0x20 [..] Call Trace: [<ffffffff815c4960>] ? nsio_rw_bytes+0x60/0x180 [<ffffffff815c6045>] nd_pfn_validate+0x75/0x320 [<ffffffff815c63a9>] nvdimm_setup_pfn+0xb9/0x5d0 [<ffffffff815c48ef>] ? devm_nsio_enable+0xff/0x110 [<ffffffff815cb699>] dax_pmem_probe+0x59/0x260 Cc: <stable@vger.kernel.org> Fixes: ab68f26 ("/dev/dax, pmem: direct access to persistent memory") Reported-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent ed99d36 commit 6a84fb4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/dax/pmem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ static int dax_pmem_probe(struct device *dev)
7878
nsio = to_nd_namespace_io(&ndns->dev);
7979

8080
/* parse the 'pfn' info block via ->rw_bytes */
81-
devm_nsio_enable(dev, nsio);
81+
rc = devm_nsio_enable(dev, nsio);
82+
if (rc)
83+
return rc;
8284
altmap = nvdimm_setup_pfn(nd_pfn, &res, &__altmap);
8385
if (IS_ERR(altmap))
8486
return PTR_ERR(altmap);

0 commit comments

Comments
 (0)