* [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak @ 2020-10-21 6:00 Ajit Khaparde 2020-10-21 14:04 ` Ajit Khaparde 2020-10-22 11:47 ` Ferruh Yigit 0 siblings, 2 replies; 6+ messages in thread From: Ajit Khaparde @ 2020-10-21 6:00 UTC (permalink / raw) To: dev; +Cc: Kalesh AP Fix a potential resource leak in case of errors during dev args parsing during device probe. Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> --- drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 562cf14ba..aa2d9e00e 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, struct bnxt *backing_bp; uint16_t num_rep; int i, ret = 0; - struct rte_kvargs *kvlist; + struct rte_kvargs *kvlist = NULL; num_rep = eth_da.nb_representor_ports; if (num_rep > BNXT_MAX_VF_REPS) { @@ -6339,49 +6339,79 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, bnxt_parse_devarg_rep_is_pf, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_BASED_PF, bnxt_parse_devarg_rep_based_pf, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_R2F, bnxt_parse_devarg_rep_q_r2f, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_F2R, bnxt_parse_devarg_rep_q_f2r, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_R2F, bnxt_parse_devarg_rep_fc_r2f, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_F2R, bnxt_parse_devarg_rep_fc_f2r, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } } ret = rte_eth_dev_create(&pci_dev->device, name, @@ -6411,6 +6441,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, } + rte_kvargs_free(kvlist); return 0; err: @@ -6419,6 +6450,8 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, */ if (num_rep > 1) bnxt_pci_remove_dev_with_reps(backing_eth_dev); + rte_errno = -ret; + rte_kvargs_free(kvlist); return ret; } -- 2.21.1 (Apple Git-122.3) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak 2020-10-21 6:00 [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak Ajit Khaparde @ 2020-10-21 14:04 ` Ajit Khaparde 2020-10-22 11:47 ` Ferruh Yigit 1 sibling, 0 replies; 6+ messages in thread From: Ajit Khaparde @ 2020-10-21 14:04 UTC (permalink / raw) To: dpdk-dev; +Cc: Kalesh AP On Tue, Oct 20, 2020 at 11:00 PM Ajit Khaparde <ajit.khaparde@broadcom.com> wrote: > > Fix a potential resource leak in case of errors during dev args > parsing during device probe. > > Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") > > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> > Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Patch applied to dpdk-next-net-brcm. > --- > drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c > index 562cf14ba..aa2d9e00e 100644 > --- a/drivers/net/bnxt/bnxt_ethdev.c > +++ b/drivers/net/bnxt/bnxt_ethdev.c > @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > struct bnxt *backing_bp; > uint16_t num_rep; > int i, ret = 0; > - struct rte_kvargs *kvlist; > + struct rte_kvargs *kvlist = NULL; > > num_rep = eth_da.nb_representor_ports; > if (num_rep > BNXT_MAX_VF_REPS) { > @@ -6339,49 +6339,79 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, > bnxt_parse_devarg_rep_is_pf, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > /* > * Handler for "rep_based_pf" devarg. > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_BASED_PF, > bnxt_parse_devarg_rep_based_pf, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > /* > * Handler for "rep_based_pf" devarg. > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_R2F, > bnxt_parse_devarg_rep_q_r2f, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > /* > * Handler for "rep_based_pf" devarg. > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_F2R, > bnxt_parse_devarg_rep_q_f2r, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > /* > * Handler for "rep_based_pf" devarg. > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_R2F, > bnxt_parse_devarg_rep_fc_r2f, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > /* > * Handler for "rep_based_pf" devarg. > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_F2R, > bnxt_parse_devarg_rep_fc_f2r, > (void *)&representor); > + if (ret) { > + ret = -EINVAL; > + goto err; > + } > } > > ret = rte_eth_dev_create(&pci_dev->device, name, > @@ -6411,6 +6441,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > > } > > + rte_kvargs_free(kvlist); > return 0; > > err: > @@ -6419,6 +6450,8 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > */ > if (num_rep > 1) > bnxt_pci_remove_dev_with_reps(backing_eth_dev); > + rte_errno = -ret; > + rte_kvargs_free(kvlist); > > return ret; > } > -- > 2.21.1 (Apple Git-122.3) > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak 2020-10-21 6:00 [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak Ajit Khaparde 2020-10-21 14:04 ` Ajit Khaparde @ 2020-10-22 11:47 ` Ferruh Yigit 2020-10-23 5:11 ` Ajit Khaparde 2020-10-23 5:12 ` [dpdk-dev] [PATCH v2] " Ajit Khaparde 1 sibling, 2 replies; 6+ messages in thread From: Ferruh Yigit @ 2020-10-22 11:47 UTC (permalink / raw) To: Ajit Khaparde, dev; +Cc: Kalesh AP On 10/21/2020 7:00 AM, Ajit Khaparde wrote: > Fix a potential resource leak in case of errors during dev args > parsing during device probe. > > Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") > > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> > Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> > --- > drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c > index 562cf14ba..aa2d9e00e 100644 > --- a/drivers/net/bnxt/bnxt_ethdev.c > +++ b/drivers/net/bnxt/bnxt_ethdev.c > @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > struct bnxt *backing_bp; > uint16_t num_rep; > int i, ret = 0; > - struct rte_kvargs *kvlist; > + struct rte_kvargs *kvlist = NULL; > > num_rep = eth_da.nb_representor_ports; > if (num_rep > BNXT_MAX_VF_REPS) { > @@ -6339,49 +6339,79 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > * Invoked as for ex: "-w 000:00:0d.0, > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > */ > + ret = > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, > bnxt_parse_devarg_rep_is_pf, > (void *)&representor); Hi Ajit, This is a different syntax, seems repeated a few times below, is it auto generated? Can it be possible to merge the assignment line with the call? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak 2020-10-22 11:47 ` Ferruh Yigit @ 2020-10-23 5:11 ` Ajit Khaparde 2020-10-23 5:12 ` [dpdk-dev] [PATCH v2] " Ajit Khaparde 1 sibling, 0 replies; 6+ messages in thread From: Ajit Khaparde @ 2020-10-23 5:11 UTC (permalink / raw) To: Ferruh Yigit; +Cc: dpdk-dev, Kalesh AP On Thu, Oct 22, 2020 at 4:47 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote: > > On 10/21/2020 7:00 AM, Ajit Khaparde wrote: > > Fix a potential resource leak in case of errors during dev args > > parsing during device probe. > > > > Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") > > > > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> > > Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> > > --- > > drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++++- > > 1 file changed, 34 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c > > index 562cf14ba..aa2d9e00e 100644 > > --- a/drivers/net/bnxt/bnxt_ethdev.c > > +++ b/drivers/net/bnxt/bnxt_ethdev.c > > @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > > struct bnxt *backing_bp; > > uint16_t num_rep; > > int i, ret = 0; > > - struct rte_kvargs *kvlist; > > + struct rte_kvargs *kvlist = NULL; > > > > num_rep = eth_da.nb_representor_ports; > > if (num_rep > BNXT_MAX_VF_REPS) { > > @@ -6339,49 +6339,79 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, > > * Invoked as for ex: "-w 000:00:0d.0, > > * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" > > */ > > + ret = > > rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, > > bnxt_parse_devarg_rep_is_pf, > > (void *)&representor); > > Hi Ajit, > > This is a different syntax, seems repeated a few times below, is it auto generated? > Can it be possible to merge the assignment line with the call? Done. I tried to improvise unnecessarily to avoid changing multiple lines. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] net/bnxt: fix a potential resource leak 2020-10-22 11:47 ` Ferruh Yigit 2020-10-23 5:11 ` Ajit Khaparde @ 2020-10-23 5:12 ` Ajit Khaparde 2020-10-23 5:17 ` Ajit Khaparde 1 sibling, 1 reply; 6+ messages in thread From: Ajit Khaparde @ 2020-10-23 5:12 UTC (permalink / raw) To: dev; +Cc: Kalesh AP Fix a potential resource leak in case of errors during dev args parsing during device probe. Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> --- v1->v2: addressed the review comment. --- drivers/net/bnxt/bnxt_ethdev.c | 66 ++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 562cf14ba4..a0e01d059d 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, struct bnxt *backing_bp; uint16_t num_rep; int i, ret = 0; - struct rte_kvargs *kvlist; + struct rte_kvargs *kvlist = NULL; num_rep = eth_da.nb_representor_ports; if (num_rep > BNXT_MAX_VF_REPS) { @@ -6339,49 +6339,74 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, - bnxt_parse_devarg_rep_is_pf, - (void *)&representor); + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, + bnxt_parse_devarg_rep_is_pf, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_BASED_PF, - bnxt_parse_devarg_rep_based_pf, - (void *)&representor); + ret = rte_kvargs_process(kvlist, + BNXT_DEVARG_REP_BASED_PF, + bnxt_parse_devarg_rep_based_pf, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_R2F, - bnxt_parse_devarg_rep_q_r2f, - (void *)&representor); + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_R2F, + bnxt_parse_devarg_rep_q_r2f, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_F2R, - bnxt_parse_devarg_rep_q_f2r, - (void *)&representor); + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_F2R, + bnxt_parse_devarg_rep_q_f2r, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_R2F, - bnxt_parse_devarg_rep_fc_r2f, - (void *)&representor); + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_R2F, + bnxt_parse_devarg_rep_fc_r2f, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf=<pf index> rep-is-pf=<VF=0 or PF=1>" */ - rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_F2R, - bnxt_parse_devarg_rep_fc_f2r, - (void *)&representor); + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_F2R, + bnxt_parse_devarg_rep_fc_f2r, + (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } } ret = rte_eth_dev_create(&pci_dev->device, name, @@ -6411,6 +6436,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, } + rte_kvargs_free(kvlist); return 0; err: @@ -6419,6 +6445,8 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, */ if (num_rep > 1) bnxt_pci_remove_dev_with_reps(backing_eth_dev); + rte_errno = -ret; + rte_kvargs_free(kvlist); return ret; } -- 2.21.1 (Apple Git-122.3) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/bnxt: fix a potential resource leak 2020-10-23 5:12 ` [dpdk-dev] [PATCH v2] " Ajit Khaparde @ 2020-10-23 5:17 ` Ajit Khaparde 0 siblings, 0 replies; 6+ messages in thread From: Ajit Khaparde @ 2020-10-23 5:17 UTC (permalink / raw) To: dpdk-dev; +Cc: Kalesh AP On Thu, Oct 22, 2020 at 10:12 PM Ajit Khaparde <ajit.khaparde@broadcom.com> wrote: > > Fix a potential resource leak in case of errors during dev args > parsing during device probe. > > Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") > > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com> > Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> > --- > v1->v2: addressed the review comment. Patch applied to dpdk-next-net-brcm. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-23 5:17 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-10-21 6:00 [dpdk-dev] [PATCH] net/bnxt: fix a potential resource leak Ajit Khaparde 2020-10-21 14:04 ` Ajit Khaparde 2020-10-22 11:47 ` Ferruh Yigit 2020-10-23 5:11 ` Ajit Khaparde 2020-10-23 5:12 ` [dpdk-dev] [PATCH v2] " Ajit Khaparde 2020-10-23 5:17 ` Ajit Khaparde
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).