[v1] net/octeontx: fix dangling pointer on failure

Message ID 1586259343-6272-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v1] net/octeontx: fix dangling pointer on failure |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed

Commit Message

Yunjian Wang April 7, 2020, 11:35 a.m. UTC
  From: Yunjian Wang <wangyunjian@huawei.com>

When octeontx_create() is cleaning up, it does not correctly set
the mac_addrs variable to NULL, which will lead to a double free.

Fixes: 9e399b88ce2f ("net/octeontx: fix memory leak of MAC address table")
CC: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Harman Kalra April 8, 2020, 12:49 p.m. UTC | #1
On Tue, Apr 07, 2020 at 07:35:43PM +0800, wangyunjian wrote:
> External Email
> 
> ----------------------------------------------------------------------
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> When octeontx_create() is cleaning up, it does not correctly set
> the mac_addrs variable to NULL, which will lead to a double free.
> 
> Fixes: 9e399b88ce2f ("net/octeontx: fix memory leak of MAC address table")
> CC: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Thanks for fixing.
Acked-by: Harman Kalra <hkalra@marvell.com>

> ---
>  drivers/net/octeontx/octeontx_ethdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> index e8aa4ec78..437abd7e5 100644
> --- a/drivers/net/octeontx/octeontx_ethdev.c
> +++ b/drivers/net/octeontx/octeontx_ethdev.c
> @@ -1181,6 +1181,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
>  
>  free_mac_addrs:
>  	rte_free(data->mac_addrs);
> +	data->mac_addrs = NULL;
>  err:
>  	if (nic)
>  		octeontx_port_close(nic);
> -- 
> 2.19.1
> 
>
  
Jerin Jacob May 4, 2020, 2:20 a.m. UTC | #2
On Wed, Apr 8, 2020 at 6:19 PM Harman Kalra <hkalra@marvell.com> wrote:
>
> On Tue, Apr 07, 2020 at 07:35:43PM +0800, wangyunjian wrote:
> > External Email
> >
> > ----------------------------------------------------------------------
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > When octeontx_create() is cleaning up, it does not correctly set
> > the mac_addrs variable to NULL, which will lead to a double free.
> >
> > Fixes: 9e399b88ce2f ("net/octeontx: fix memory leak of MAC address table")
> > CC: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>
> Thanks for fixing.
> Acked-by: Harman Kalra <hkalra@marvell.com>


Applied to dpdk-next-net-mrvl/master. Thanks


>
> > ---
> >  drivers/net/octeontx/octeontx_ethdev.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> > index e8aa4ec78..437abd7e5 100644
> > --- a/drivers/net/octeontx/octeontx_ethdev.c
> > +++ b/drivers/net/octeontx/octeontx_ethdev.c
> > @@ -1181,6 +1181,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
> >
> >  free_mac_addrs:
> >       rte_free(data->mac_addrs);
> > +     data->mac_addrs = NULL;
> >  err:
> >       if (nic)
> >               octeontx_port_close(nic);
> > --
> > 2.19.1
> >
> >
  

Patch

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index e8aa4ec78..437abd7e5 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1181,6 +1181,7 @@  octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 
 free_mac_addrs:
 	rte_free(data->mac_addrs);
+	data->mac_addrs = NULL;
 err:
 	if (nic)
 		octeontx_port_close(nic);