Skip to content

Commit c31898c

Browse files
committed
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: <[email protected]> Fixes: 4a826c8 ("libnvdimm: namespace indices: read and validate") Reported-by: Krzysztof Rusocki <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent f6adcca commit c31898c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/nvdimm/dimm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ static int nvdimm_probe(struct device *dev)
6767
ndd->ns_next = nd_label_next_nsindex(ndd->ns_current);
6868
nd_label_copy(ndd, to_next_namespace_index(ndd),
6969
to_current_namespace_index(ndd));
70-
rc = nd_label_reserve_dpa(ndd);
71-
if (ndd->ns_current >= 0)
72-
nvdimm_set_aliasing(dev);
70+
if (ndd->ns_current >= 0) {
71+
rc = nd_label_reserve_dpa(ndd);
72+
if (rc == 0)
73+
nvdimm_set_aliasing(dev);
74+
}
7375
nvdimm_clear_locked(dev);
7476
nvdimm_bus_unlock(dev);
7577

0 commit comments

Comments
 (0)