From: Stephen Hemminger <stephen@networkplumber.org>
To: "Renyong Wan" <wanry@yunsilicon.com>
Cc: <dev@dpdk.org>, <nana@yunsilicon.com>, <qianr@yunsilicon.com>,
<zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>
Subject: Re: [PATCH 0/2] net/xsc: fix two issues reported by GCC analyzer
Date: Sun, 15 Nov 2026 13:41:49 -0800 [thread overview]
Message-ID: <20261115134149.051d5ace@phoenix.local> (raw)
In-Reply-To: <179453942560.1554.11439899391590171416@yunsilicon.com>
On Fri, 13 Nov 2026 11:10:25 +0800
"Renyong Wan" <wanry@yunsilicon.com> wrote:
> >From 0fe3f49419330852df7d2a82fcf179fa6f80a9a0 Mon Sep 17 00:00:00 2001
> From: Renyong Wan <wanry@yunsilicon.com>
> Date: Fri, 13 Nov 2026 10:44:51 +0800
> Subject: [PATCH 0/2] net/xsc: fix two issues reported by GCC analyzer
>
> Two fixes for net/xsc coming out of the GCC -fanalyzer report.
>
> 45: when rte_malloc_virt2iova() fails, the jumbo buffer is leaked and
> RTE_BAD_IOVA ends up in the WQE.
>
> 46: xsc_dev_init() leaks a structure on the dev_ops failure path, and
> the Tx queue allocation is dereferenced without a NULL check.
>
> The two patches are independent.
>
> Renyong Wan (2):
> net/xsc: fix jumbo buffer on IOVA conversion failure
> net/xsc: fix leak and missing NULL check
>
> drivers/net/xsc/xsc_dev.c | 1 +
> drivers/net/xsc/xsc_ethdev.c | 6 ++++++
> drivers/net/xsc/xsc_rx.c | 5 ++++-
> 3 files changed, 11 insertions(+), 1 deletion(-)
AI review picked up some possible issues:
Subject: Re: [PATCH 1/2] net/xsc: fix jumbo buffer on IOVA conversion failure
Both patches apply to main and build with -Dwerror=true. Fixes tags
resolve and point at 25.03 commits, so Cc: stable is correct.
Patch 2/2 has no findings.
[PATCH 1/2] net/xsc: fix jumbo buffer on IOVA conversion failure
Warning: the fix stops the use of RTE_BAD_IOVA, but the fallback path
it lands in is still unsafe.
When rte_malloc_virt2iova() fails it will fail the same way on every
retry (e.g. IOVA as PA without access to physical addresses). With
this patch every WQE of every Rx queue now does rte_malloc(),
virt2iova, rte_free() and logs at ERR level: up to 1024 log lines per
queue on each start.
Worse, the fallback sets seg->seg_len = XSC_MAX_RECV_LEN (9800) on a
segment that points at an mbuf whose data room is only
rte_pktmbuf_data_len(mbuf). The second segment exists so oversized
frames land in the jumbo buffer; without it, a frame larger than the
mbuf is DMA'd past the end of the mbuf. "Rely on mtu" only holds if
the MTU fits in the mbuf, which nothing here checks.
Allocate the buffer once before the loop and fail queue start on
error instead of degrading per WQE:
static int
xsc_rxq_initialize(struct xsc_dev *xdev, struct xsc_rxq_data *rxq_data)
{
...
if (rx_ds_num != 1 && xdev->jumbo_buffer_va == NULL) {
void *buf = rte_malloc(NULL, XSC_MAX_RECV_LEN, 0);
rte_iova_t iova;
if (buf == NULL) {
PMD_DRV_LOG(ERR, "Failed to alloc jumbo buffer");
return -ENOMEM;
}
iova = rte_malloc_virt2iova(buf);
if (iova == RTE_BAD_IOVA) {
PMD_DRV_LOG(ERR, "Failed to get IOVA of jumbo buffer");
rte_free(buf);
return -EFAULT;
}
xdev->jumbo_buffer_pa = buf;
xdev->jumbo_buffer_va = (void *)iova;
}
for (i = 0; i != wqe_n; ++i) {
/* fill seg and seg_next, no allocation here */
}
...
return 0;
}
and in the caller:
ret = xsc_rxq_initialize(xdev, rxq_data);
if (ret != 0) {
rte_errno = -ret;
goto set_qp_fail;
}
Info: xdev->jumbo_buffer_pa is never freed. There is no rte_free() of
it anywhere in the driver, so it leaks on device close. Free it in
the close/uninit path (separate patch is fine).
Info: the names are swapped relative to content: jumbo_buffer_pa holds
the virtual address and jumbo_buffer_va holds the IOVA (as a void *).
That is how the original bug went unnoticed. Consider
"void *jumbo_buf; rte_iova_t jumbo_iova;" in struct xsc_dev, which
also removes the casts.
prev parent reply other threads:[~2026-11-15 21:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 3:10 [PATCH 0/2] net/xsc: fix two issues reported by GCC analyzer Renyong Wan
2026-11-13 3:10 ` [PATCH 1/2] net/xsc: fix jumbo buffer on IOVA conversion failure Renyong Wan
2026-11-13 3:10 ` [PATCH 2/2] net/xsc: fix leak and missing NULL check Renyong Wan
2026-11-15 21:41 ` Stephen Hemminger [this message]
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=20261115134149.051d5ace@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=nana@yunsilicon.com \
--cc=qianr@yunsilicon.com \
--cc=wanry@yunsilicon.com \
--cc=xudw@yunsilicon.com \
--cc=zhangxx@yunsilicon.com \
/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