From: lirongqing <lirongqing@baidu.com>
To: Sagi Grimberg <sagi@grimberg.me>,
Max Gurtovoy <mgurtovoy@nvidia.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Jenny Derzhavetz <jennyf@mellanox.com>,
Doug Ledford <dledford@redhat.com>, <linux-rdma@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: Li RongQing <lirongqing@baidu.com>
Subject: [PATCH] RDMA/iser: Unmap Data-Out header DMA on send failure
Date: Mon, 21 Sep 2026 11:39:49 +0800 [thread overview]
Message-ID: <20260921033949.1803-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
iser_send_data_out() maps the tx_desc header for DMA via
iser_initialize_task_headers() (which sets tx_desc->mapped and calls
ib_dma_map_single()). The normal completion path hands unmap and free
off to the iser_dataout_comp() completion callback.
However, if a later step fails -- the bounds check
(buf_offset + data_seg_len > data_len) or iser_post_send() -- control
jumps to send_data_out_error, which only calls kmem_cache_free() without
ib_dma_unmap_single(). Because the WR was never posted, the completion
callback never fires to unmap it, so the DMA mapping is leaked.
Unmap the header DMA in the error path when tx_desc->mapped is set,
mirroring the pattern already used in iscsi_iser_cleanup_task().
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/infiniband/ulp/iser/iser_initiator.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 7ea6888..9685e0a 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -464,6 +464,10 @@ int iser_send_data_out(struct iscsi_conn *conn, struct iscsi_task *task,
return 0;
send_data_out_error:
+ if (tx_desc->mapped)
+ ib_dma_unmap_single(iser_conn->ib_conn.device->ib_device,
+ tx_desc->dma_addr, ISER_HEADERS_LEN,
+ DMA_TO_DEVICE);
kmem_cache_free(ig.desc_cache, tx_desc);
iser_err("conn %p failed err %d\n", conn, err);
return err;
--
2.9.4
next reply other threads:[~2026-09-21 3:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 3:39 lirongqing [this message]
2026-09-21 3:57 ` [PATCH] RDMA/iser: Unmap Data-Out header DMA on send failure sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921033949.1803-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=dledford@redhat.com \
--cc=jennyf@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox