Re: [PATCH 4.4 110/268] nvme-pci: Fix nvme queue cleanup if IRQ setup fails

From: Ben Hutchings
Date: Wed Jun 13 2018 - 12:14:45 EST


On Mon, 2018-05-28 at 12:01 +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.ÂÂIf anyone has any objections, please let me know.
>
> ------------------
>
> From: Jianchao Wang <jianchao.w.wang@xxxxxxxxxx>
>
> [ Upstream commit f25a2dfc20e3a3ed8fe6618c331799dd7bd01190 ]
>
> This patch fixes nvme queue cleanup if requesting an IRQ handler for
> the queue's vector fails. It does this by resetting the cq_vector to
> the uninitialized value of -1 so it is ignored for a controller reset.
>
> Signed-off-by: Jianchao Wang <jianchao.w.wang@xxxxxxxxxx>
> [changelog updates, removed misc whitespace changes]
> Signed-off-by: Keith Busch <keith.busch@xxxxxxxxx>
> Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> Âdrivers/nvme/host/pci.c |ÂÂÂÂ5 ++++-
> Â1 file changed, 4 insertions(+), 1 deletion(-)
>
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1583,7 +1583,7 @@ static int nvme_create_queue(struct nvme
> Â nvmeq->cq_vector = qid - 1;
> Â result = adapter_alloc_cq(dev, qid, nvmeq);
> Â if (result < 0)
> - return result;
> + goto release_vector;
> Â
> Â result = adapter_alloc_sq(dev, qid, nvmeq);
> Â if (result < 0)
> @@ -1597,9 +1597,12 @@ static int nvme_create_queue(struct nvme
> Â return result;
> Â
> Â release_sq:
> + dev->online_queues--;

This addition looks wrong. dev->online_queues is incremented by
nvme_init_queue(), but this function only calls that at a point where
it is sure to succeed. So why would a failure path need to decrement
it?

Ben.

> Â adapter_delete_sq(dev, qid);
> Â release_cq:
> Â adapter_delete_cq(dev, qid);
> + release_vector:
> + nvmeq->cq_vector = -1;
> Â return result;
> Â}
> Â
>
>
>
--
Ben Hutchings, Software Developer  Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom