* [PATCH 1/4] net/gve: free Rx mbufs if allocation fails on ring setup
[not found] <20250826000337.3922883-1-joshwash@google.com>
@ 2025-08-26 0:03 ` Joshua Washington
0 siblings, 0 replies; only message in thread
From: Joshua Washington @ 2025-08-26 0:03 UTC (permalink / raw)
To: Jeroen de Borst, Joshua Washington, Rushil Gupta, Praveen Kaligineedi
Cc: dev, stable, Ankit Garg, Ziwei Xiao
When creating new RX rings, one less than the number of buffers in the
ring need to be allocated. It is possible that only a part of the
allocation is successful, resulting in a failure to create the rings.
In this case, the driver should free the buffers which were successfully
allocated to avoid a memory leak in case the application does not
automatically exit.
Fixes: 265daac8a53a ("net/gve: fix mbuf allocation memory leak for DQ Rx")
Cc: stable@dpdk.org
Signed-off-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Ankit Garg <nktgrg@google.com>
Reviewed-by: Ziwei Xiao <ziweixiao@google.com>
---
drivers/net/gve/gve_rx_dqo.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c
index 0103add985..cd85d90bb6 100644
--- a/drivers/net/gve/gve_rx_dqo.c
+++ b/drivers/net/gve/gve_rx_dqo.c
@@ -376,14 +376,13 @@ gve_rxq_mbufs_alloc_dqo(struct gve_rx_queue *rxq)
rxq->stats.no_mbufs_bulk++;
for (i = 0; i < rx_mask; i++) {
nmb = rte_pktmbuf_alloc(rxq->mpool);
- if (!nmb)
- break;
+ if (!nmb) {
+ rxq->stats.no_mbufs++;
+ gve_release_rxq_mbufs_dqo(rxq);
+ return -ENOMEM;
+ }
rxq->sw_ring[i] = nmb;
}
- if (i < rxq->nb_rx_desc - 1) {
- rxq->stats.no_mbufs += rx_mask - i;
- return -ENOMEM;
- }
}
for (i = 0; i < rx_mask; i++) {
--
2.51.0.rc1.167.g924127e9c0-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-26 0:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250826000337.3922883-1-joshwash@google.com>
2025-08-26 0:03 ` [PATCH 1/4] net/gve: free Rx mbufs if allocation fails on ring setup Joshua Washington
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).