Commit be49aba0 authored by Keith Busch's avatar Keith Busch Committed by Stefan Bader

nvme-pci: initialize queue memory before interrupts

BugLink: https://bugs.launchpad.net/bugs/1784409

commit 161b8be2 upstream.

A spurious interrupt before the nvme driver has initialized the completion
queue may inadvertently cause the driver to believe it has a completion
to process. This may result in a NULL dereference since the nvmeq's tags
are not set at this point.

The patch initializes the host's CQ memory so that a spurious interrupt
isn't mistaken for a real completion.
Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
[bwh: Backported to 4.4: adjust context]
Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent a3a07d51
...@@ -1341,11 +1341,11 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) ...@@ -1341,11 +1341,11 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
if (result < 0) if (result < 0)
goto release_cq; goto release_cq;
nvme_init_queue(nvmeq, qid);
result = queue_request_irq(dev, nvmeq, nvmeq->irqname); result = queue_request_irq(dev, nvmeq, nvmeq->irqname);
if (result < 0) if (result < 0)
goto release_sq; goto release_sq;
nvme_init_queue(nvmeq, qid);
return result; return result;
release_sq: release_sq:
...@@ -1464,6 +1464,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) ...@@ -1464,6 +1464,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
goto free_nvmeq; goto free_nvmeq;
nvmeq->cq_vector = 0; nvmeq->cq_vector = 0;
nvme_init_queue(nvmeq, 0);
result = queue_request_irq(dev, nvmeq, nvmeq->irqname); result = queue_request_irq(dev, nvmeq, nvmeq->irqname);
if (result) { if (result) {
nvmeq->cq_vector = -1; nvmeq->cq_vector = -1;
...@@ -2064,7 +2065,6 @@ static void nvme_reset_work(struct work_struct *work) ...@@ -2064,7 +2065,6 @@ static void nvme_reset_work(struct work_struct *work)
if (result) if (result)
goto unmap; goto unmap;
nvme_init_queue(dev->queues[0], 0);
result = nvme_alloc_admin_tags(dev); result = nvme_alloc_admin_tags(dev);
if (result) if (result)
goto disable; goto disable;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment