Skip to content

Commit 33a5608

Browse files
committed
libnvdimm, namespace: fix btt claim class crash
Maurice reports: BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 IP: holder_class_store+0x253/0x2b0 [libnvdimm] ...while trying to reconfigure an NVDIMM-N namespace into 'sector' / 'btt' mode. The crash points to this line: (gdb) li *(holder_class_store+0x253) 0x7773 is in holder_class_store (drivers/nvdimm/namespace_devs.c:1420). 1415 for (i = 0; i < nd_region->ndr_mappings; i++) { 1416 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; 1417 struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); 1418 struct nd_namespace_index *nsindex; 1419 1420 nsindex = to_namespace_index(ndd, ndd->ns_current); ...where we are failing because ndd is NULL due to NVDIMM-N dimms not supporting labels. Long story short, default to the BTTv1 format in the label-less / NVDIMM-N case. Fixes: 14e4945 ("libnvdimm, btt: BTT updates for UEFI 2.7 format") Cc: <[email protected]> Cc: Vishal Verma <[email protected]> Reported-by: Maurice A. Saldivar <[email protected]> Tested-by: Maurice A. Saldivar <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 5e75fe3 commit 33a5608

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,15 @@ static int btt_claim_class(struct device *dev)
14171417
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
14181418
struct nd_namespace_index *nsindex;
14191419

1420+
/*
1421+
* If any of the DIMMs do not support labels the only
1422+
* possible BTT format is v1.
1423+
*/
1424+
if (!ndd) {
1425+
loop_bitmask = 0;
1426+
break;
1427+
}
1428+
14201429
nsindex = to_namespace_index(ndd, ndd->ns_current);
14211430
if (nsindex == NULL)
14221431
loop_bitmask |= 1;

0 commit comments

Comments
 (0)