net/virtio: fix interrupt handle leak
authorGaoxiang Liu <liugaoxiang@huawei.com>
Mon, 26 Jul 2021 14:42:05 +0000 (22:42 +0800)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 28 Jul 2021 06:29:27 +0000 (08:29 +0200)
Free memory of interrupt handle in virtio_user_dev_uninit() to
avoid memory leak.
when virtio user dev closes, memory of interrupt handle is not freed
that is allocated in virtio_user_fill_intr_handle().

Fixes: 3d4fb6fd2505 ("net/virtio-user: support Rx interrupt")
Cc: stable@dpdk.org
Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_user/virtio_user_dev.c

index 1cd1e95..16c5871 100644 (file)
@@ -654,6 +654,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 void
 virtio_user_dev_uninit(struct virtio_user_dev *dev)
 {
+       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
+
+       if (eth_dev->intr_handle) {
+               free(eth_dev->intr_handle);
+               eth_dev->intr_handle = NULL;
+       }
+
        virtio_user_stop_device(dev);
 
        rte_mem_event_callback_unregister(VIRTIO_USER_MEM_EVENT_CLB_NAME, dev);