summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLei Yin <yinlei2@lenovo.com>2023-04-06 17:39:11 +0200
committerChristoph Hellwig <hch@lst.de>2023-04-13 08:59:04 +0200
commitd4f1d5f7a4d8d998739c3d699476cd0247d580c6 (patch)
tree518b4edaae3d735b7e407a4f2343b6718eb6bbbf /drivers
parentnvme: fix async event trace event (diff)
downloadlinux-d4f1d5f7a4d8d998739c3d699476cd0247d580c6.tar.xz
linux-d4f1d5f7a4d8d998739c3d699476cd0247d580c6.zip
nvme: fix double blk_mq_complete_request for timeout request with low probability
When nvme_cancel_tagset traverses all tagsets and executes nvme_cancel_request, this request may be executing blk_mq_free_request that is called by nvme_rdma_complete_timed_out/nvme_tcp_complete_timed_out. When blk_mq_free_request executes to WRITE_ONCE(rq->state, MQ_RQ_IDLE) and __blk_mq_free_request(rq), it will cause double blk_mq_complete_request for this request, and it will cause a null pointer error in the second execution of this function because rq->mq_hctx has set to NULL in first execution. Signed-off-by: Lei Yin <yinlei2@lenovo.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nvme/host/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 0699365461f4..6c1e7d6709e0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -450,8 +450,8 @@ bool nvme_cancel_request(struct request *req, void *data)
dev_dbg_ratelimited(((struct nvme_ctrl *) data)->device,
"Cancelling I/O %d", req->tag);
- /* don't abort one completed request */
- if (blk_mq_request_completed(req))
+ /* don't abort one completed or idle request */
+ if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT)
return true;
nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;