[PATCH v3 44/44] net/netvsc: use LIST_FOREACH_SAFE

Stephen Hemminger
2025-11-03T16:53:57Z

Fix use after free in in remove_cache_list by using LIST_FOREACH_SAFE

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/netvsc/hn_ethdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index dc765e88f7..bc243bf229 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -1479,14 +1479,14 @@ static int populate_cache_list(void)

static void remove_cache_list(void)
{
- struct da_cache *cache;
+ struct da_cache *cache, *tmp;

rte_spinlock_lock(&netvsc_lock);
da_cache_usage--;
if (da_cache_usage)
goto out;

- LIST_FOREACH(cache, &da_cache_list, list) {
+ LIST_FOREACH_SAFE(cache, &da_cache_list, list, tmp) {
LIST_REMOVE(cache, list);
free(cache);
}
--
2.51.0