device-dax: check devm_nsio_enable() return value
authorDan Williams <dan.j.williams@intel.com>
Fri, 28 Oct 2016 21:34:51 +0000 (14:34 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 28 Oct 2016 21:35:25 +0000 (14:35 -0700)
commit6a84fb4b4e439a8ef0ce19ec7e7661ad76f655c9
tree20ca54f7eb6c1bc09cab3e33090181d81ae142ee
parented99d3673e082b78b20208f346d2cd375483a779
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: ab68f2622136 ("/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>
drivers/dax/pmem.c