From: Pengzhen Liu Date: Fri, 27 Oct 2017 03:54:09 +0000 (+0800) Subject: net/virtio: fix memory leak on failure X-Git-Tag: spdx-start~825 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=43d18765c027;p=dpdk.git net/virtio: fix memory leak on failure In function eth_virtio_dev_init(), dynamic memory stored in "eth_dev->data->mac_addrs" variable and it is not freed when function return, this is a possible memory leak. Fixes: 8ced1542f7a3 ("net/virtio: eth_dev->data->mac_addrs is not freed") Cc: stable@dpdk.org Signed-off-by: Pengzhen Liu Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 87ac2bee6d..e0328f61d1 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1620,13 +1620,13 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) if (!hw->virtio_user_dev) { ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), hw); if (ret) - return ret; + goto out; } /* reset device and negotiate default features */ ret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES); if (ret < 0) - return ret; + goto out; /* Setup interrupt callback */ if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) @@ -1634,6 +1634,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) virtio_interrupt_handler, eth_dev); return 0; + +out: + rte_free(eth_dev->data->mac_addrs); + return ret; } static int