diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index c3a818f3d637..26fa0f2bfc76 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -193,8 +193,10 @@ nvme_ctrlr_fail(struct nvme_controller *ctrlr) ctrlr->is_failed = TRUE; nvme_qpair_fail(&ctrlr->adminq); - for (i = 0; i < ctrlr->num_io_queues; i++) - nvme_qpair_fail(&ctrlr->ioq[i]); + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_qpair_fail(&ctrlr->ioq[i]); + } nvme_notify_fail_consumers(ctrlr); } @@ -397,7 +399,7 @@ nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) while (status.done == FALSE) pause("nvme", 1); if (nvme_completion_is_error(&status.cpl)) { - nvme_printf(ctrlr, "nvme_set_num_queues failed!\n"); + nvme_printf(ctrlr, "nvme_ctrlr_set_num_qpairs failed!\n"); return (ENXIO); } diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index d7d4c74ade4d..299117128782 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -1000,6 +1000,9 @@ nvme_qpair_fail(struct nvme_qpair *qpair) struct nvme_tracker *tr; struct nvme_request *req; + if (!mtx_initialized(&qpair->lock)) + return; + mtx_lock(&qpair->lock); while (!STAILQ_EMPTY(&qpair->queued_req)) {