* [PATCH 2/4] nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request
@ 2026-07-29 10:58 Guixin Liu
2026-07-29 11:32 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Guixin Liu @ 2026-07-29 10:58 UTC (permalink / raw)
To: Justin Tee, Naresh Gottumukkala, Paul Ely, Keith Busch,
Jens Axboe, Christoph Hellwig, Sagi Grimberg, Johannes Thumshirn,
James Smart, Jay Freyensee
Cc: linux-nvme
__nvme_fc_init_request() maps cmd_iu and then rsp_iu for DMA. If the
rsp_iu mapping fails, the original code only recorded the error and fell
through: it left the already-mapped cmd_iu unmapped and still marked the
op as FCPOP_STATE_IDLE before returning. Since blk-mq does not call
.exit_request() when .init_request() fails, the cmd_iu mapping is leaked
for every op whose rsp_iu mapping fails.
Jump to an error path on rsp_iu mapping failure that unmaps cmd_iu and
returns the error without marking the op idle, so it stays in the
FCPOP_STATE_UNINIT state set by the initial memset().
Fixes: e399441de911 ("nvme-fabrics: Add host support for FC transport")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/host/fc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 04363b9c4489..40f9da2833ff 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2100,9 +2100,15 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
dev_err(ctrl->dev,
"FCP Op failed - rspiu dma mapping failed.\n");
ret = -EFAULT;
+ goto out_unmap;
}
atomic_set(&op->state, FCPOP_STATE_IDLE);
+ return 0;
+
+out_unmap:
+ fc_dma_unmap_single(ctrl->lport->dev, op->fcp_req.cmddma,
+ sizeof(op->cmd_iu), DMA_TO_DEVICE);
out_on_error:
return ret;
}
--
2.43.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/4] nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request
2026-07-29 10:58 [PATCH 2/4] nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request Guixin Liu
@ 2026-07-29 11:32 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-07-29 11:32 UTC (permalink / raw)
To: Guixin Liu
Cc: Justin Tee, Naresh Gottumukkala, Paul Ely, Keith Busch,
Jens Axboe, Christoph Hellwig, Sagi Grimberg, Johannes Thumshirn,
James Smart, Jay Freyensee, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 10:58 [PATCH 2/4] nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request Guixin Liu
2026-07-29 11:32 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox