From: Joshua Washington <joshwash@google.com>
To: Jeroen de Borst <jeroendb@google.com>,
Joshua Washington <joshwash@google.com>,
Rushil Gupta <rushilg@google.com>,
Praveen Kaligineedi <pkaligineedi@google.com>
Cc: dev@dpdk.org, stable@dpdk.org, Ankit Garg <nktgrg@google.com>,
Ziwei Xiao <ziweixiao@google.com>
Subject: [PATCH 1/4] net/gve: free Rx mbufs if allocation fails on ring setup
Date: Mon, 25 Aug 2025 17:03:34 -0700 [thread overview]
Message-ID: <20250826000337.3922883-2-joshwash@google.com> (raw)
In-Reply-To: <20250826000337.3922883-1-joshwash@google.com>
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
next prev parent reply other threads:[~2025-08-26 0:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 0:03 [PATCH 0/4] net/gve: out of order completion processing for DQO Joshua Washington
2025-08-26 0:03 ` Joshua Washington [this message]
2025-08-26 0:03 ` [PATCH 2/4] net/gve: add datapath-specific logging for gve Joshua Washington
2025-08-26 0:03 ` [PATCH 3/4] net/gve: support for out of order completions on DQ Tx Joshua Washington
2025-08-26 0:03 ` [PATCH 4/4] net/gve: support for out of order completions on DQ Rx Joshua Washington
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=20250826000337.3922883-2-joshwash@google.com \
--to=joshwash@google.com \
--cc=dev@dpdk.org \
--cc=jeroendb@google.com \
--cc=nktgrg@google.com \
--cc=pkaligineedi@google.com \
--cc=rushilg@google.com \
--cc=stable@dpdk.org \
--cc=ziweixiao@google.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).