From: Long Li <[email protected]>

Device arguments (devargs) allocated during VF hotplug were not being
freed when the hotplug context was cleaned up, causing a memory leak.

The devargs are allocated in netvsc_hotadd_callback() via
rte_devargs_parse() and stored in the hotadd context structure. They
must be freed with rte_devargs_reset() before freeing the context.

Free devargs in both cleanup paths:
- netvsc_hotplug_retry() after hotplug attempt completes
- hn_dev_close() when canceling pending hotplug operations

Fixes: 7fc4c0997b04 ("net/netvsc: fix hot adding multiple VF PCI devices")
Cc: [email protected]
Signed-off-by: Long Li <[email protected]>
---
 drivers/net/netvsc/hn_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 62e6f49d3d..6327dc2132 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -716,6 +716,7 @@ static void netvsc_hotplug_retry(void *args)
        LIST_REMOVE(hot_ctx, list);
        rte_spinlock_unlock(&hv->hotadd_lock);
 
+       rte_devargs_reset(d);
        free(hot_ctx);
 }
 
@@ -1131,6 +1132,7 @@ hn_dev_close(struct rte_eth_dev *dev)
                hot_ctx = LIST_FIRST(&hv->hotadd_list);
                rte_eal_alarm_cancel(netvsc_hotplug_retry, hot_ctx);
                LIST_REMOVE(hot_ctx, list);
+               rte_devargs_reset(&hot_ctx->da);
                free(hot_ctx);
        }
        rte_spinlock_unlock(&hv->hotadd_lock);
-- 
2.43.0

Reply via email to