From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, bruce.richardson@intel.com,
yuanx.wang@intel.com, stable@dpdk.org
Subject: [PATCH] net/ice: fix memory leak in scalar Rx
Date: Fri, 17 Jan 2025 17:52:05 +0000 [thread overview]
Message-ID: <20250117175205.1598739-1-vladimir.medvedkin@intel.com> (raw)
If the buffer splitting feature is configured and the payload mbuf
allocation fails, the previously allocated header mbuf may be returned not
fully initialized or a memory leak may occur.
This patch handles this case correctly by freeing the corresponding header
buffer.
Fixes: 629dad3ef325 ("net/ice: support buffer split in scalar Rx")
Cc: yuanx.wang@intel.com
Cc: stable@dpdk.org
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
drivers/net/ice/ice_rxtx.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 0c7106c7e0..f58df9bdfe 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -484,6 +484,7 @@ ice_alloc_rx_queue_mbufs(struct ice_rx_queue *rxq)
struct rte_mbuf *mbuf_pay;
mbuf_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
if (unlikely(!mbuf_pay)) {
+ rte_pktmbuf_free(mbuf);
PMD_DRV_LOG(ERR, "Failed to allocate payload mbuf for RX");
return -ENOMEM;
}
@@ -1900,6 +1901,8 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq)
diag_pay = rte_mempool_get_bulk(rxq->rxseg[1].mp,
(void *)mbufs_pay, rxq->rx_free_thresh);
if (unlikely(diag_pay != 0)) {
+ rte_mempool_put_bulk(rxq->mp, (void *)rxep,
+ rxq->rx_free_thresh);
PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk");
return -ENOMEM;
}
@@ -2607,6 +2610,13 @@ ice_recv_pkts(void *rx_queue,
nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
if (unlikely(!nmb_pay)) {
rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
+ rxe->mbuf = NULL;
+ nb_hold--;
+ if (unlikely(rx_id == 0))
+ rx_id = rxq->nb_rx_desc;
+
+ rx_id--;
+ rte_pktmbuf_free(nmb);
break;
}
--
2.43.0
reply other threads:[~2025-01-17 17:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250117175205.1598739-1-vladimir.medvedkin@intel.com \
--to=vladimir.medvedkin@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=yuanx.wang@intel.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;
as well as URLs for NNTP newsgroup(s).