From: Chen Zhao <ch3nzhao@gmail.com>
To: weh@microsoft.com
Cc: thomas@monjalon.net, stephen@networkplumber.org, dev@dpdk.org,
stable@dpdk.org
Subject: [PATCH] net/netvsc: fix event buffer leak on realloc failure
Date: Sun, 25 Oct 2026 01:46:33 +0000 [thread overview]
Message-ID: <20261025014634.3295418-1-ch3nzhao@gmail.com> (raw)
rte_realloc() failure overwrites event_buf and leaks the old allocation.
Save the old pointer and free it on failure before resetting event_sz.
Fixes: 1f2766b7ee02 ("net/netvsc: resize event buffer as needed")
Cc: sthemmin@microsoft.com
Cc: stable@dpdk.org
Signed-off-by: Chen Zhao <ch3nzhao@gmail.com>
---
.mailmap | 1 +
drivers/net/netvsc/hn_rxtx.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.mailmap b/.mailmap
index 6d9e262cfb..deae6514dd 100644
--- a/.mailmap
+++ b/.mailmap
@@ -267,6 +267,7 @@ Charles Myers <charles.myers@spirent.com>
Charles Stoll <charles.stoll@intel.com>
Chas Williams <3chas3@gmail.com> <chas3@att.com>
Chas Williams <3chas3@gmail.com> <ciwillia@brocade.com>
+Chen Zhao <ch3nzhao@gmail.com>
Chenbo Xia <chenbox@nvidia.com> <chenbo.xia@intel.com>
Cheng Jiang <honest.jiang@foxmail.com> <cheng1.jiang@intel.com>
Cheng Liu <liucheng11@huawei.com>
diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 6f536610f2..4db6c933c9 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -1131,15 +1131,19 @@ uint32_t hn_process_events(struct hn_data *hv, uint16_t queue_id,
if (unlikely(ret == -ENOBUFS)) {
/* event buffer not large enough to read ring */
+ void *old_buf = rxq->event_buf;
PMD_DRV_LOG(DEBUG,
"event buffer expansion (need %u)", len);
rxq->event_sz = len + len / 4;
- rxq->event_buf = rte_realloc(rxq->event_buf, rxq->event_sz,
+ rxq->event_buf = rte_realloc(old_buf, rxq->event_sz,
RTE_CACHE_LINE_SIZE);
if (rxq->event_buf)
goto retry;
- /* out of memory, no more events now */
+ /*
+ * out of memory, free the old buffer, no more events now
+ */
+ rte_free(old_buf);
rxq->event_sz = 0;
break;
}
--
2.43.0
next reply other threads:[~2026-10-25 1:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 1:46 Chen Zhao [this message]
2026-10-25 2:18 ` [PATCH] net/netvsc: fix event buffer leak on realloc failure Chen Zhao
2026-10-25 15:55 ` Stephen Hemminger
2026-10-26 16:58 ` 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=20261025014634.3295418-1-ch3nzhao@gmail.com \
--to=ch3nzhao@gmail.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=weh@microsoft.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