[PATCH v4 4/6] net/netvsc: fix event callback leak on rxfilter failure

Long Li
2026-03-03T20:54:50Z

In hn_dev_start(), if hn_rndis_set_rxfilter() fails after registering
the device event callback, the function returns without unregistering
the callback. Unregister it before returning on error.

Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/net/netvsc/hn_ethdev.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 19721b4829..5e954b8812 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -1043,16 +1043,22 @@ hn_dev_start(struct rte_eth_dev *dev)
NDIS_PACKET_TYPE_BROADCAST |
NDIS_PACKET_TYPE_ALL_MULTICAST |
NDIS_PACKET_TYPE_DIRECTED);
- if (error)
+ if (error) {
+ rte_dev_event_callback_unregister(NULL,
+ netvsc_hotadd_callback, hv);
return error;
+ }

error = hn_vf_start(dev);
- if (error)
+ if (error) {
hn_rndis_set_rxfilter(hv, 0);
+ rte_dev_event_callback_unregister(NULL,
+ netvsc_hotadd_callback, hv);
+ return error;
+ }

/* Initialize Link state */
- if (error == 0)
- hn_dev_link_update(dev, 0);
+ hn_dev_link_update(dev, 0);

for (i = 0; i < hv->num_queues; i++) {
dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
--
2.43.0