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

Long Li
2025-11-04T00:29:33Z

> Fix use after free in in remove_cache_list by using LIST_FOREACH_SAFE
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Thank you.

Reviewed-by: Long Li <longli@microsoft.com>

> ---
> 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