Skip to content

Commit 72d4471

Browse files
author
Christoph Hellwig
committed
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: b2ce4d9 ("nvme-multipath: set bdi capabilities once") Reported-by: Avinash M N <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]>
1 parent ea43d97 commit 72d4471

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/nvme/host/multipath.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,11 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
672672
}
673673

674674
if (bdi_cap_stable_pages_required(ns->queue->backing_dev_info)) {
675-
struct backing_dev_info *info =
676-
ns->head->disk->queue->backing_dev_info;
675+
struct gendisk *disk = ns->head->disk;
677676

678-
info->capabilities |= BDI_CAP_STABLE_WRITES;
677+
if (disk)
678+
disk->queue->backing_dev_info->capabilities |=
679+
BDI_CAP_STABLE_WRITES;
679680
}
680681
}
681682

0 commit comments

Comments
 (0)