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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Oct 2020 06:02:50 +0000 (08:02 +0200)
commit7d2120bc38b94381f04c18b4ad49b62ecd83c882
tree93a71d43f34186b5d94ce7cd92a797ba488f9d0b
parent189c154bc593f6fe592f322fee5dd2ff4c0613b0
nvme-pci: fix NULL req in completion handler

[ Upstream commit 50b7c24390a53c78de546215282fb52980f1d7b7 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/pci.c