Return-Path: Received: from mga06.intel.com ([134.134.136.31]:25309 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728477AbeHCWlq (ORCPT ); Fri, 3 Aug 2018 18:41:46 -0400 From: Jon Derrick To: stable@vger.kernel.org Cc: Jon Derrick , Sagi Grimberg , Keith Busch , Christoph Hellwig Subject: [PATCH v4.14 2/2] nvme-pci: Fix queue double allocations Date: Fri, 3 Aug 2018 14:39:33 -0600 Message-Id: <1533328773-3159-2-git-send-email-jonathan.derrick@intel.com> In-Reply-To: <1533328773-3159-1-git-send-email-jonathan.derrick@intel.com> References: <1533328773-3159-1-git-send-email-jonathan.derrick@intel.com> Sender: stable-owner@vger.kernel.org List-ID: commit 62314e405fa101dbb82563394f9dfc225e3f1167 upstream 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") CC: Sagi Grimberg CC: Keith Busch CC: Christoph Hellwig Signed-off-by: Jon Derrick --- drivers/nvme/host/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 51e8589..bfc42f2 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1246,6 +1246,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) -- 1.8.3.1