summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPengzhen Liu <liupengzhen3@huawei.com>2017-10-27 11:54:09 +0800
committerThomas Monjalon <thomas@monjalon.net>2017-11-12 19:50:43 +0100
commit43d18765c027722424b2b0176fd4856c33ad7e6c (patch)
treee5aa9a21c572fd49f24e711db6f4cbe4218b8056
parent9bc2cbb007c0a3335c5582357ae9f6d37ea0b654 (diff)
downloaddpdk-draft-cli-43d18765c027722424b2b0176fd4856c33ad7e6c.zip
dpdk-draft-cli-43d18765c027722424b2b0176fd4856c33ad7e6c.tar.gz
dpdk-draft-cli-43d18765c027722424b2b0176fd4856c33ad7e6c.tar.xz
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 <liupengzhen3@huawei.com> Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
-rw-r--r--drivers/net/virtio/virtio_ethdev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 87ac2be..e0328f6 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