Skip to contentSkip to conversation

nvme/pci: Fix queue double allocations

PATCH New Keith Busch 3 participants 3 messages Jan 23, 2018 – Jan 24, 2018 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme/pci: Fix queue double allocations

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 at intel.com>
---
 drivers/nvme/host/pci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/pci.c +3 -0
index a2ffb557b616..c46c239cc1ff 100644
@@ -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)
Signature · 1 line
2.13.6
maintainer Applied
#1 lore raw

PATCH 1/1 nvme/pci: Fix queue double allocations

Thanks,

applied to nvme-4.16.

maintainer
#2 lore raw

PATCH 1/1 nvme/pci: Fix queue double allocations

In reply to Keith Busch
Quoted 6 lines

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 at intel.com>
Reviewed-by Sagi Grimberg <sagi at grimberg.me>

I wish we wouldn't have to rely on nvme_alloc_queue for this though..