diff mbox

[dpdk-dev,v2] net/i40e: fix memory leak if VF init fails

Message ID 1505244231-51364-1-git-send-email-jingjing.wu@intel.com (mailing list archive)
State Superseded, archived
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jingjing Wu Sept. 12, 2017, 7:23 p.m. UTC
Cc: stable@dpdk.org
Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v2 change:
 - free aq_resp at err_aq

 drivers/net/i40e/i40e_ethdev_vf.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Xing, Beilei Sept. 13, 2017, 3:22 a.m. UTC | #1
> -----Original Message-----
> From: Wu, Jingjing
> Sent: Wednesday, September 13, 2017 3:24 AM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] net/i40e: fix memory leak if VF init fails
> 
> Cc: stable@dpdk.org
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> 
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
> v2 change:
>  - free aq_resp at err_aq
> 
>  drivers/net/i40e/i40e_ethdev_vf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index f6d8293..1206af1 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1317,7 +1317,9 @@ i40evf_init_vf(struct rte_eth_dev *dev)
> 
>  err_alloc:
>  	rte_free(vf->vf_res);
> +	vf->vsi_res = NULL;
>  err_aq:
> +	rte_free(vf->aq_resp);

Seems it's inappropriate to free aq_resp here, if reset NIC failed, vf->aq_resp is not allocated yet.

/* Reset VF and wait until it's complete */
        if (i40evf_reset_vf(hw)) {
                PMD_INIT_LOG(ERR, "reset NIC failed");
                goto err_aq;
        }

How about adding a new error branch?

>  	i40e_shutdown_adminq(hw); /* ignore error */
>  err:
>  	return -1;
> --
> 2.7.4
Jingjing Wu Sept. 13, 2017, 5:39 a.m. UTC | #2
> -----Original Message-----
> From: Xing, Beilei
> Sent: Wednesday, September 13, 2017 11:23 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH v2] net/i40e: fix memory leak if VF init fails
> 
> 
> 
> > -----Original Message-----
> > From: Wu, Jingjing
> > Sent: Wednesday, September 13, 2017 3:24 AM
> > To: Xing, Beilei <beilei.xing@intel.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; stable@dpdk.org
> > Subject: [PATCH v2] net/i40e: fix memory leak if VF init fails
> >
> > Cc: stable@dpdk.org
> > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> >
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> > ---
> > v2 change:
> >  - free aq_resp at err_aq
> >
> >  drivers/net/i40e/i40e_ethdev_vf.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> > b/drivers/net/i40e/i40e_ethdev_vf.c
> > index f6d8293..1206af1 100644
> > --- a/drivers/net/i40e/i40e_ethdev_vf.c
> > +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> > @@ -1317,7 +1317,9 @@ i40evf_init_vf(struct rte_eth_dev *dev)
> >
> >  err_alloc:
> >  	rte_free(vf->vf_res);
> > +	vf->vsi_res = NULL;
> >  err_aq:
> > +	rte_free(vf->aq_resp);
> 
> Seems it's inappropriate to free aq_resp here, if reset NIC failed, vf->aq_resp is
> not allocated yet.
> 
> /* Reset VF and wait until it's complete */
>         if (i40evf_reset_vf(hw)) {
>                 PMD_INIT_LOG(ERR, "reset NIC failed");
>                 goto err_aq;
>         }
> 
> How about adding a new error branch?

Yes, a new version will be sent.

Thanks
Jingjing
diff mbox

Patch

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index f6d8293..1206af1 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1317,7 +1317,9 @@  i40evf_init_vf(struct rte_eth_dev *dev)
 
 err_alloc:
 	rte_free(vf->vf_res);
+	vf->vsi_res = NULL;
 err_aq:
+	rte_free(vf->aq_resp);
 	i40e_shutdown_adminq(hw); /* ignore error */
 err:
 	return -1;