libnvdimm, dimm: fix dpa reservation vs uninitialized label area
authorDan Williams <dan.j.williams@intel.com>
Fri, 6 Apr 2018 18:25:38 +0000 (11:25 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sat, 7 Apr 2018 05:59:32 +0000 (22:59 -0700)
commit74bbff3cf7d10e607641650f2bd973e4e93eab0e
treeac6b8caa3a30a7cb924e3c4a0056d5b6199f4fde
parentb84b40ec5eb769042ef7ee5aa1dc85d38429e6e3
libnvdimm, dimm: fix dpa reservation vs uninitialized label area

At initialization time the 'dimm' driver caches a copy of the memory
device's label area and reserves address space for each of the
namespaces defined.

However, as can be seen below, the reservation occurs even when the
index blocks are invalid:

 nvdimm nmem0: nvdimm_init_config_data: len: 131072 rc: 0
 nvdimm nmem0: config data size: 131072
 nvdimm nmem0: __nd_label_validate: nsindex0 labelsize 1 invalid
 nvdimm nmem0: __nd_label_validate: nsindex1 labelsize 1 invalid
 nvdimm nmem0: : pmem-6025e505: 0x1000000000 @ 0xf50000000 reserve <-- bad

Gate dpa reservation on the presence of valid index blocks.

Cc: <stable@vger.kernel.org>
Fixes: 5720869e2ab1 ("libnvdimm: namespace indices: read and validate")
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/nvdimm/dimm.c