Skip to contentSkip to conversation

nvme: fix a crash in nvme_mpath_add_disk

PATCH In review Christoph Hellwig 3 participants 3 messages Jun 29, 2020 NVMe

lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

PATCH v2 1/1 nvme: fix a crash in nvme_mpath_add_disk

For private namespaces ns->head_disk is NULL, so add a NULL check before updating the BDI capabilities.

Fixes b2ce4d90690b ("nvme-multipath: set bdi capabilities once")

---

And now with the compile fix actually picked up in the git commit as well..

 drivers/nvme/host/multipath.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/nvme/host/multipath.c +4 -3
index 18d084ed497ef3..66509472fe06ae 100644
@@ -672,10 +672,11 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
 	}
 
 	if (bdi_cap_stable_pages_required(ns->queue->backing_dev_info)) {
-		struct backing_dev_info *info =
-					ns->head->disk->queue->backing_dev_info;
+		struct gendisk *disk = ns->head->disk;
 
-		info->capabilities |= BDI_CAP_STABLE_WRITES;
+		if (disk)
+			disk->queue->backing_dev_info->capabilities |=
+					BDI_CAP_STABLE_WRITES;
 	}
 }
 
Signature · 7 lines
2.26.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme