Blob Blame History Raw
From: Keith Busch <keith.busch@intel.com>
Date: Tue, 23 Jan 2018 09:16:19 -0700
Subject: nvme-pci: Fix queue double allocations
Patch-mainline: v4.16-rc1
Git-commit: 62314e405fa101dbb82563394f9dfc225e3f1167
References: FATE#323952, FATE#322506

The queue count says the highest queue that's been allocated, so don't
reallocate a queue lower than that.

Fixes: 147b27e4bd0 ("nvme-pci: allocate device queues storage space at probe")
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/host/pci.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1382,6 +1382,9 @@ static int nvme_alloc_queue(struct nvme_
 {
 	struct nvme_queue *nvmeq = &dev->queues[qid];
 
+	if (dev->ctrl.queue_count > qid)
+		return 0;
+
 	nvmeq->cqes = dma_zalloc_coherent(dev->dev, CQ_SIZE(depth),
 					  &nvmeq->cq_dma_addr, GFP_KERNEL);
 	if (!nvmeq->cqes)