Avoid dereferencing unintialized elements in the error path.

Some drives sometimes have errors for things like setting the number
of queue entries in the submission queue. The error paths taken for
these drives ensure a panic dereferencing uninialized data.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2017-03-07 23:06:41 +00:00
parent 05ee702af6
commit 824073fbd6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314889
2 changed files with 8 additions and 3 deletions

View File

@ -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);
}

View File

@ -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)) {