nvme-pci: Fix nvme queue cleanup if IRQ setup fails
authorJianchao Wang <jianchao.w.wang@oracle.com>
Thu, 15 Feb 2018 11:13:41 +0000 (19:13 +0800)
committerKeith Busch <keith.busch@intel.com>
Mon, 26 Feb 2018 08:53:32 +0000 (01:53 -0700)
This patch fixes nvme queue cleanup if requesting an IRQ handler for
the queue's vector fails. It does this by resetting the cq_vector to
the uninitialized value of -1 so it is ignored for a controller reset.

Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
[changelog updates, removed misc whitespace changes]
Signed-off-by: Keith Busch <keith.busch@intel.com>
drivers/nvme/host/pci.c

index 6fe7af00a1f42a7dcb3354ac49db499cef6f9c88..022b070e60b7fdfda4f38524b2a9c8357717fb0f 100644 (file)
@@ -1452,7 +1452,7 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
        nvmeq->cq_vector = qid - 1;
        result = adapter_alloc_cq(dev, qid, nvmeq);
        if (result < 0)
-               return result;
+               goto release_vector;
 
        result = adapter_alloc_sq(dev, qid, nvmeq);
        if (result < 0)
@@ -1466,9 +1466,12 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
        return result;
 
  release_sq:
+       dev->online_queues--;
        adapter_delete_sq(dev, qid);
  release_cq:
        adapter_delete_cq(dev, qid);
+ release_vector:
+       nvmeq->cq_vector = -1;
        return result;
 }