From: WenTao Liang <vulab@iscas.ac.cn>
To: ntb@lists.linux.dev
Cc: jdmason@kudzu.us, dave.jiang@intel.com, allenbh@gmail.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
WenTao Liang <vulab@iscas.ac.cn>,
Greg KH <gregkh@linuxfoundation.org>
Subject: [PATCH v2] ntb: fix tx descriptor leak on dmaengine_submit failure
Date: Sun, 28 Jun 2026 16:33:01 +0800 [thread overview]
Message-ID: <20260628083301.9781-1-vulab@iscas.ac.cn> (raw)
When dmaengine_submit fails after dma_set_unmap has been called, the
error path err_set_unmap only calls dmaengine_unmap_put once, but the
unmap object has two references (one from dmaengine_get_unmap_data and
one from dma_set_unmap held by the tx descriptor). The tx descriptor
itself is never freed, so its reference to unmap is never released,
causing a kref leak and a dangling pointer in the freed descriptor.
Replace dmaengine_unmap_put with dmaengine_desc_put(txd) in the
err_set_unmap path to properly release the tx descriptor, which will also
drop the unmap reference it holds.
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Fixes: 282a2feeb9bf ("NTB: Use DMA Engine to Transmit and Receive")
Cc: stable@vger.kernel.org
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
Changes in v2:
- Fix patch format based on reviewer feedback
- Resend to ntb@lists.linux.dev (remove invalid googlegroups address)
---
drivers/ntb/ntb_transport.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 7cabc82305d6..28091ec5a74e 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1572,7 +1572,7 @@ static int ntb_async_rx_submit(struct ntb_queue_entry *entry, void *offset)
return 0;
err_set_unmap:
- dmaengine_unmap_put(unmap);
+ dmaengine_desc_put(txd);
err_get_unmap:
dmaengine_unmap_put(unmap);
err:
@@ -1896,7 +1896,7 @@ static int ntb_async_tx_submit(struct ntb_transport_qp *qp,
return 0;
err_set_unmap:
- dmaengine_unmap_put(unmap);
+ dmaengine_desc_put(txd);
err_get_unmap:
dmaengine_unmap_put(unmap);
err:
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-06-28 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 8:33 WenTao Liang [this message]
2026-06-29 4:37 ` Greg KH
2026-08-15 2:05 ` kernel test robot
2026-08-16 3:01 ` kernel test robot
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=20260628083301.9781-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=allenbh@gmail.com \
--cc=dave.jiang@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=ntb@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®