nvme-pci: Fix queue double allocations
authorKeith Busch <keith.busch@intel.com>
Tue, 23 Jan 2018 16:16:19 +0000 (09:16 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 23 Jan 2018 19:15:34 +0000 (20:15 +0100)
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>
drivers/nvme/host/pci.c

index a2ffb557b616f3ae1d3088f22e066a2ce71d4f17..c46c239cc1ff01fd1cf094323596a3900213e1d8 100644 (file)
@@ -1384,6 +1384,9 @@ static int nvme_alloc_queue(struct nvme_dev *dev, int qid,
 {
        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)