From: "Renyong Wan" <wanry@yunsilicon.com>
To: <dev@dpdk.org>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
<nana@yunsilicon.com>, <qianr@yunsilicon.com>,
<zhangxx@yunsilicon.com>, <xudw@yunsilicon.com>,
<stable@dpdk.org>
Subject: [PATCH v4 2/3] net/xsc: fix leak and missing null check
Date: Tue, 17 Nov 2026 19:14:20 +0800 [thread overview]
Message-ID: <1794914060.189871@yunsilicon.com> (raw)
In-Reply-To: <1794914060.606144@yunsilicon.com>
xsc_dev_init() leaks the structure when the dev_ops lookup fails. Free
it there: xsc_dev_uninit() cannot be used, as xsc_dev_close()
dereferences xdev->dev_ops.
xsc_ethdev_tx_queue_setup() misses the NULL check on the
rte_malloc_socket() result. Return -ENOMEM, as the Rx path does.
Fixes: fb7d4f7ae39a ("net/xsc: add device initialization")
Fixes: 488262986eee ("net/xsc: support Rx and Tx queue setup")
Cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Renyong Wan <wanry@yunsilicon.com>
---
drivers/net/xsc/xsc_dev.c | 1 +
drivers/net/xsc/xsc_ethdev.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/drivers/net/xsc/xsc_dev.c b/drivers/net/xsc/xsc_dev.c
index 953409a9..f048efd7 100644
--- a/drivers/net/xsc/xsc_dev.c
+++ b/drivers/net/xsc/xsc_dev.c
@@ -375,6 +375,7 @@ xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **xdev)
d->dev_ops = xsc_dev_ops_get(pci_dev->kdrv);
if (d->dev_ops == NULL) {
PMD_DRV_LOG(ERR, "Could not get dev_ops, kdrv=%d", pci_dev->kdrv);
+ rte_free(d);
return -ENODEV;
}
diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c
index 20d6f58f..a5c3e4a6 100644
--- a/drivers/net/xsc/xsc_ethdev.c
+++ b/drivers/net/xsc/xsc_ethdev.c
@@ -545,6 +545,12 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
txq = rte_malloc_socket(NULL, sizeof(*txq) + desc_n * sizeof(struct rte_mbuf *),
RTE_CACHE_LINE_SIZE, socket);
+ if (txq == NULL) {
+ PMD_DRV_LOG(ERR, "Port %u create txq idx %d failure",
+ dev->data->port_id, idx);
+ rte_errno = ENOMEM;
+ return -rte_errno;
+ }
txq->offloads = conf->offloads | dev->data->dev_conf.txmode.offloads;
txq->priv = priv;
txq->socket = socket;
next prev parent reply other threads:[~2026-11-17 11:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:14 [PATCH v4 0/3] net/xsc: fix issues reported by GCC analyzer Renyong Wan
2026-11-17 11:14 ` [PATCH v4 1/3] net/xsc: fix jumbo buffer allocation and leak Renyong Wan
2026-11-17 11:14 ` [PATCH v4 3/3] net/xsc: rename jumbo buffer fields Renyong Wan
2026-11-17 11:14 ` Renyong Wan [this message]
2026-11-17 17:04 ` [PATCH v4 0/3] net/xsc: fix issues reported by GCC analyzer Stephen Hemminger
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=1794914060.189871@yunsilicon.com \
--to=wanry@yunsilicon.com \
--cc=dev@dpdk.org \
--cc=nana@yunsilicon.com \
--cc=qianr@yunsilicon.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--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