nvme-pci: fix NULL req in completion handler
authorXianting Tian <tian.xianting@h3c.com>
Tue, 22 Sep 2020 06:25:17 +0000 (14:25 +0800)
committerChristoph Hellwig <hch@lst.de>
Tue, 22 Sep 2020 15:49:55 +0000 (17:49 +0200)
commit50b7c24390a53c78de546215282fb52980f1d7b7
tree55b34dabf43b8f26584984f7259a6874e33992a5
parent59e330f8ff7ada7aa64fa422f6adf22a45152a7e
nvme-pci: fix NULL req in completion handler

Currently, we use nvmeq->q_depth as the upper limit for a valid tag in
nvme_handle_cqe(), it is not correct. Because the available tag number
is recorded in tagset, which is not equal to nvmeq->q_depth.

The nvme driver registers interrupts for queues before initializing the
tagset, because it uses the number of successful request_irq() calls to
configure the tagset parameters. This allows a race condition with the
current tag validity check if the controller happens to produce an
interrupt with a corrupted CQE before the tagset is initialized.

Replace the driver's indirect tag check with the one already provided by
the block layer.

Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/pci.c