net/virtio: fix dangling pointer on failure

Message ID 20190415144818.26600-1-aconole@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix dangling pointer on failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Aaron Conole April 15, 2019, 2:48 p.m. UTC
  When eth_virtio_dev_init() is cleaning up, it does not correctly set
the mac_addrs variable to NULL, which will lead to a double free.

Found during unit-test fixes.

Fixes: 43d18765c027 ("net/virtio: fix memory leak on failure")
Cc: stable@dpdk.org
Reported-by: Michael Santana <msantana@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 drivers/net/virtio/virtio_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Tiwei Bie April 16, 2019, 5:19 a.m. UTC | #1
On Mon, Apr 15, 2019 at 10:48:18AM -0400, Aaron Conole wrote:
> When eth_virtio_dev_init() is cleaning up, it does not correctly set
> the mac_addrs variable to NULL, which will lead to a double free.
> 
> Found during unit-test fixes.
> 
> Fixes: 43d18765c027 ("net/virtio: fix memory leak on failure")
> Cc: stable@dpdk.org
> Reported-by: Michael Santana <msantana@redhat.com>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
  
Maxime Coquelin April 17, 2019, 7:52 a.m. UTC | #2
On 4/15/19 4:48 PM, Aaron Conole wrote:
> When eth_virtio_dev_init() is cleaning up, it does not correctly set
> the mac_addrs variable to NULL, which will lead to a double free.
> 
> Found during unit-test fixes.
> 
> Fixes: 43d18765c027 ("net/virtio: fix memory leak on failure")
> Cc: stable@dpdk.org
> Reported-by: Michael Santana <msantana@redhat.com>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>   drivers/net/virtio/virtio_ethdev.c | 1 +
>   1 file changed, 1 insertion(+)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 2272bb2e5..d25c08f0a 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1862,6 +1862,7 @@  eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 
 out:
 	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
 	return ret;
 }