Re: [PATCH][next] mlxsw: spectrum: fix uninitialized value in err
On 10/01/2017 07:27 PM, Colin King wrote: > From: Colin Ian King <colin.k...@canonical.com> > > In the unlikely event that mfc->mfc_un.res.ttls[i] is 255 for all > values of i from 0 to MAXIVS-1, the err is not set at all and hence > has a garbage value on the error return at the end of the function, > so initialize it to 0. Also, the error return check on err and goto > to err: inside the for loop makes it impossible for err to be zero > at the end of the for loop, so we can remove the redundant err check > at the end of the loop. > > Detected by CoverityScan CID#1457207 ("Unitialized scalar value") Thanks for that! Reviewed-by: Yotam Gigi <yot...@mellanox.com> > > Fixes: c011ec1bbfd6 ("mlxsw: spectrum: Add the multicast routing offloading > logic") > Signed-off-by: Colin Ian King <colin.k...@canonical.com> > --- > drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > index 09120259a45d..4aaf6ca1be7c 100644 > --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > @@ -349,7 +349,7 @@ mlxsw_sp_mr_route4_create(struct mlxsw_sp_mr_table > *mr_table, > { > struct mlxsw_sp_mr_route_vif_entry *rve, *tmp; > struct mlxsw_sp_mr_route *mr_route; > - int err; > + int err = 0; > int i; > > /* Allocate and init a new route and fill it with parameters */ > @@ -376,8 +376,6 @@ mlxsw_sp_mr_route4_create(struct mlxsw_sp_mr_table > *mr_table, > } > } > mlxsw_sp_mr_route_ivif_link(mr_route, _table->vifs[mfc->mfc_parent]); > - if (err) > - goto err; > > mr_route->route_action = mlxsw_sp_mr_route_action(mr_route); > return mr_route;
Re: [PATCH][next] mlxsw: spectrum: fix uninitialized value in err
On 10/01/2017 07:27 PM, Colin King wrote: > From: Colin Ian King > > In the unlikely event that mfc->mfc_un.res.ttls[i] is 255 for all > values of i from 0 to MAXIVS-1, the err is not set at all and hence > has a garbage value on the error return at the end of the function, > so initialize it to 0. Also, the error return check on err and goto > to err: inside the for loop makes it impossible for err to be zero > at the end of the for loop, so we can remove the redundant err check > at the end of the loop. > > Detected by CoverityScan CID#1457207 ("Unitialized scalar value") Thanks for that! Reviewed-by: Yotam Gigi > > Fixes: c011ec1bbfd6 ("mlxsw: spectrum: Add the multicast routing offloading > logic") > Signed-off-by: Colin Ian King > --- > drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > index 09120259a45d..4aaf6ca1be7c 100644 > --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c > @@ -349,7 +349,7 @@ mlxsw_sp_mr_route4_create(struct mlxsw_sp_mr_table > *mr_table, > { > struct mlxsw_sp_mr_route_vif_entry *rve, *tmp; > struct mlxsw_sp_mr_route *mr_route; > - int err; > + int err = 0; > int i; > > /* Allocate and init a new route and fill it with parameters */ > @@ -376,8 +376,6 @@ mlxsw_sp_mr_route4_create(struct mlxsw_sp_mr_table > *mr_table, > } > } > mlxsw_sp_mr_route_ivif_link(mr_route, _table->vifs[mfc->mfc_parent]); > - if (err) > - goto err; > > mr_route->route_action = mlxsw_sp_mr_route_action(mr_route); > return mr_route;
Re: [PATCH][net-next] net/mlxfw: remove redundant goto on error check
On 06/06/2017 01:47 PM, Colin King wrote: > From: Colin Ian King <colin.k...@canonical.com> > > The check to see of err is set and the subsequent goto is extraneous > as the next statement is where the goto is jumping to. Remove this > redundant check and goto. > > Detected by CoverityScan, CID#1437734 ("Identical code for > different branches") > > Signed-off-by: Colin Ian King <colin.k...@canonical.com> > --- > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > index 7e9589061d30..628150d28061 100644 > --- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > +++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > @@ -492,8 +492,6 @@ static int mlxfw_mfa2_file_cb_offset_xz(const struct > mlxfw_mfa2_file *mfa2_file, > dec_buf.out_pos = 0; > dec_buf.out_size = size; > err = mlxfw_mfa2_xz_dec_run(xz_dec, _buf, ); > - if (err) > - goto out; > out: > xz_dec_end(xz_dec); > return err; Thanks! Acked-by: Yotam Gigi <yot...@mellanox.com>
Re: [PATCH][net-next] net/mlxfw: remove redundant goto on error check
On 06/06/2017 01:47 PM, Colin King wrote: > From: Colin Ian King > > The check to see of err is set and the subsequent goto is extraneous > as the next statement is where the goto is jumping to. Remove this > redundant check and goto. > > Detected by CoverityScan, CID#1437734 ("Identical code for > different branches") > > Signed-off-by: Colin Ian King > --- > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > index 7e9589061d30..628150d28061 100644 > --- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > +++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c > @@ -492,8 +492,6 @@ static int mlxfw_mfa2_file_cb_offset_xz(const struct > mlxfw_mfa2_file *mfa2_file, > dec_buf.out_pos = 0; > dec_buf.out_size = size; > err = mlxfw_mfa2_xz_dec_run(xz_dec, _buf, ); > - if (err) > - goto out; > out: > xz_dec_end(xz_dec); > return err; Thanks! Acked-by: Yotam Gigi
Re: [PATCH net-next] net/mlxfw: select CONFIG_XZ_DEC
On 05/30/2017 12:26 PM, Arnd Bergmann wrote: > The new mlxfw code fails to build without the xz library: > > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.o: In function > `mlxfw_mfa2_xz_dec_run': > :(.text.mlxfw_mfa2_xz_dec_run+0x8): undefined reference to `xz_dec_run' > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.o: In function > `mlxfw_mfa2_file_component_get': > :(.text.mlxfw_mfa2_file_component_get+0x218): undefined reference to > `xz_dec_init' > :(.text.mlxfw_mfa2_file_component_get+0x2c0): undefined reference to > `xz_dec_end' > > This adds a Kconfig 'select' statement for it, which is also what > the other user of that library has. > > Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash > process") > Signed-off-by: Arnd Bergmann <a...@arndb.de> > --- > drivers/net/ethernet/mellanox/mlxfw/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/mellanox/mlxfw/Kconfig > b/drivers/net/ethernet/mellanox/mlxfw/Kconfig > index 56b60ac7bc34..2b21af8a2b1d 100644 > --- a/drivers/net/ethernet/mellanox/mlxfw/Kconfig > +++ b/drivers/net/ethernet/mellanox/mlxfw/Kconfig > @@ -4,3 +4,4 @@ > > config MLXFW > tristate "mlxfw" if COMPILE_TEST > + select XZ_DEC Thanks! Acked-by: Yotam Gigi <yot...@mellanox.com>
Re: [PATCH net-next] net/mlxfw: select CONFIG_XZ_DEC
On 05/30/2017 12:26 PM, Arnd Bergmann wrote: > The new mlxfw code fails to build without the xz library: > > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.o: In function > `mlxfw_mfa2_xz_dec_run': > :(.text.mlxfw_mfa2_xz_dec_run+0x8): undefined reference to `xz_dec_run' > drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.o: In function > `mlxfw_mfa2_file_component_get': > :(.text.mlxfw_mfa2_file_component_get+0x218): undefined reference to > `xz_dec_init' > :(.text.mlxfw_mfa2_file_component_get+0x2c0): undefined reference to > `xz_dec_end' > > This adds a Kconfig 'select' statement for it, which is also what > the other user of that library has. > > Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash > process") > Signed-off-by: Arnd Bergmann > --- > drivers/net/ethernet/mellanox/mlxfw/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/mellanox/mlxfw/Kconfig > b/drivers/net/ethernet/mellanox/mlxfw/Kconfig > index 56b60ac7bc34..2b21af8a2b1d 100644 > --- a/drivers/net/ethernet/mellanox/mlxfw/Kconfig > +++ b/drivers/net/ethernet/mellanox/mlxfw/Kconfig > @@ -4,3 +4,4 @@ > > config MLXFW > tristate "mlxfw" if COMPILE_TEST > + select XZ_DEC Thanks! Acked-by: Yotam Gigi
RE: [PATCH] [net-next] mlxsw: add psample dependency for spectrum
>-Original Message- >From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org] On >Behalf Of Arnd Bergmann >Sent: Monday, February 06, 2017 6:27 PM >To: Jiri Pirko <j...@mellanox.com>; Ido Schimmel <ido...@mellanox.com> >Cc: Arnd Bergmann <a...@arndb.de>; David S. Miller <da...@davemloft.net>; >Vadim Pasternak <vad...@mellanox.com>; Elad Raz <el...@mellanox.com>; Ivan >Vecera <c...@cera.cz>; net...@vger.kernel.org; linux-kernel@vger.kernel.org >Subject: [PATCH] [net-next] mlxsw: add psample dependency for spectrum > >When PSAMPLE is a loadable module, spectrum must not be built-in: > >drivers/net/built-in.o: In function `mlxsw_sp_rx_listener_sample_func': >spectrum.c:(.text+0xe357e): undefined reference to `psample_sample_packet' > >This adds a Kconfig dependency to enforce usable configurations. > >Fixes: 98d0f7b9acda ("mlxsw: spectrum: Add packet sample offloading support") >Signed-off-by: Arnd Bergmann <a...@arndb.de> Acked-by: Yotam Gigi <yot...@mellanox.com> >--- > drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig >b/drivers/net/ethernet/mellanox/mlxsw/Kconfig >index 76a7574c3c7d..ef23eaedc2ff 100644 >--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig >+++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig >@@ -73,6 +73,7 @@ config MLXSW_SWITCHX2 > config MLXSW_SPECTRUM > tristate "Mellanox Technologies Spectrum support" > depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && >VLAN_8021Q >+ depends on PSAMPLE || PSAMPLE=n > select PARMAN > default m > ---help--- >-- >2.9.0
RE: [PATCH] [net-next] mlxsw: add psample dependency for spectrum
>-Original Message- >From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org] On >Behalf Of Arnd Bergmann >Sent: Monday, February 06, 2017 6:27 PM >To: Jiri Pirko ; Ido Schimmel >Cc: Arnd Bergmann ; David S. Miller ; >Vadim Pasternak ; Elad Raz ; Ivan >Vecera ; net...@vger.kernel.org; linux-kernel@vger.kernel.org >Subject: [PATCH] [net-next] mlxsw: add psample dependency for spectrum > >When PSAMPLE is a loadable module, spectrum must not be built-in: > >drivers/net/built-in.o: In function `mlxsw_sp_rx_listener_sample_func': >spectrum.c:(.text+0xe357e): undefined reference to `psample_sample_packet' > >This adds a Kconfig dependency to enforce usable configurations. > >Fixes: 98d0f7b9acda ("mlxsw: spectrum: Add packet sample offloading support") >Signed-off-by: Arnd Bergmann Acked-by: Yotam Gigi >--- > drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig >b/drivers/net/ethernet/mellanox/mlxsw/Kconfig >index 76a7574c3c7d..ef23eaedc2ff 100644 >--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig >+++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig >@@ -73,6 +73,7 @@ config MLXSW_SWITCHX2 > config MLXSW_SPECTRUM > tristate "Mellanox Technologies Spectrum support" > depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && >VLAN_8021Q >+ depends on PSAMPLE || PSAMPLE=n > select PARMAN > default m > ---help--- >-- >2.9.0
RE: linux-next: manual merge of the net-next tree with Linus' tree
>-Original Message- >From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org] On >Behalf Of Stephen Rothwell >Sent: Thursday, February 02, 2017 3:50 AM >To: David Miller <da...@davemloft.net>; Networking <net...@vger.kernel.org> >Cc: linux-n...@vger.kernel.org; linux-kernel@vger.kernel.org; Yotam Gigi ><yot...@mellanox.com> >Subject: linux-next: manual merge of the net-next tree with Linus' tree > >Hi all, > >Today's linux-next merge of the net-next tree got a conflict in: > > net/sched/cls_matchall.c > >between commit: > > fd62d9f5c575 ("net/sched: matchall: Fix configuration race") > >from Linus' tree and commit: > > ec2507d2a306 ("net/sched: cls_matchall: Fix error path") > >from the net-next tree. > >I fixed it up (see below) and can carry the fix as necessary. This >is now fixed as far as linux-next is concerned, but any non trivial >conflicts should be mentioned to your upstream maintainer when your tree >is submitted for merging. You may also want to consider cooperating >with the maintainer of the conflicting tree to minimise any particularly >complex conflicts. Looks good. Thanks! > >-- >Cheers, >Stephen Rothwell > >diff --cc net/sched/cls_matchall.c >index b12bc2abea93,fcecf5aac666.. >--- a/net/sched/cls_matchall.c >+++ b/net/sched/cls_matchall.c >@@@ -118,19 -141,24 +118,24 @@@ static int mall_set_parms(struct net *n > struct tcf_exts e; > int err; > >- tcf_exts_init(, TCA_MATCHALL_ACT, 0); >+ err = tcf_exts_init(, TCA_MATCHALL_ACT, 0); >+ if (err) >+ return err; > err = tcf_exts_validate(net, tp, tb, est, , ovr); > if (err < 0) >- return err; >+ goto errout; > > if (tb[TCA_MATCHALL_CLASSID]) { > - f->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); > - tcf_bind_filter(tp, >res, base); > + head->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); > + tcf_bind_filter(tp, >res, base); > } > > - tcf_exts_change(tp, >exts, ); > + tcf_exts_change(tp, >exts, ); > > return 0; >+ errout: >+ tcf_exts_destroy(); >+ return err; > } > > static int mall_change(struct net *net, struct sk_buff *in_skb, >@@@ -162,39 -194,43 +167,44 @@@ > return -EINVAL; > } > > - f = kzalloc(sizeof(*f), GFP_KERNEL); > - if (!f) > + new = kzalloc(sizeof(*new), GFP_KERNEL); > + if (!new) > return -ENOBUFS; > >- tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); > - err = tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); >++ err = tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); >+ if (err) >+ goto err_exts_init; > > if (!handle) > handle = 1; > - f->handle = handle; > - f->flags = flags; > + new->handle = handle; > + new->flags = flags; > > - err = mall_set_parms(net, tp, f, base, tb, tca[TCA_RATE], ovr); > + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], ovr); > if (err) >- goto errout; >+ goto err_set_parms; > > if (tc_should_offload(dev, tp, flags)) { > - err = mall_replace_hw_filter(tp, f, (unsigned long) f); > + err = mall_replace_hw_filter(tp, new, (unsigned long) new); > if (err) { > if (tc_skip_sw(flags)) >- goto errout; >+ goto err_replace_hw_filter; > else > err = 0; > } > } > > - *arg = (unsigned long) f; > - rcu_assign_pointer(head->filter, f); > - > + *arg = (unsigned long) head; > + rcu_assign_pointer(tp->root, new); > + if (head) > + call_rcu(>rcu, mall_destroy_rcu); > return 0; > >- errout: >+ err_replace_hw_filter: >+ err_set_parms: > - tcf_exts_destroy(>exts); >++ tcf_exts_destroy(>exts); >+ err_exts_init: > - kfree(f); > + kfree(new); > return err; > } >
RE: linux-next: manual merge of the net-next tree with Linus' tree
>-Original Message- >From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org] On >Behalf Of Stephen Rothwell >Sent: Thursday, February 02, 2017 3:50 AM >To: David Miller ; Networking >Cc: linux-n...@vger.kernel.org; linux-kernel@vger.kernel.org; Yotam Gigi > >Subject: linux-next: manual merge of the net-next tree with Linus' tree > >Hi all, > >Today's linux-next merge of the net-next tree got a conflict in: > > net/sched/cls_matchall.c > >between commit: > > fd62d9f5c575 ("net/sched: matchall: Fix configuration race") > >from Linus' tree and commit: > > ec2507d2a306 ("net/sched: cls_matchall: Fix error path") > >from the net-next tree. > >I fixed it up (see below) and can carry the fix as necessary. This >is now fixed as far as linux-next is concerned, but any non trivial >conflicts should be mentioned to your upstream maintainer when your tree >is submitted for merging. You may also want to consider cooperating >with the maintainer of the conflicting tree to minimise any particularly >complex conflicts. Looks good. Thanks! > >-- >Cheers, >Stephen Rothwell > >diff --cc net/sched/cls_matchall.c >index b12bc2abea93,fcecf5aac666.. >--- a/net/sched/cls_matchall.c >+++ b/net/sched/cls_matchall.c >@@@ -118,19 -141,24 +118,24 @@@ static int mall_set_parms(struct net *n > struct tcf_exts e; > int err; > >- tcf_exts_init(, TCA_MATCHALL_ACT, 0); >+ err = tcf_exts_init(, TCA_MATCHALL_ACT, 0); >+ if (err) >+ return err; > err = tcf_exts_validate(net, tp, tb, est, , ovr); > if (err < 0) >- return err; >+ goto errout; > > if (tb[TCA_MATCHALL_CLASSID]) { > - f->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); > - tcf_bind_filter(tp, >res, base); > + head->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); > + tcf_bind_filter(tp, >res, base); > } > > - tcf_exts_change(tp, >exts, ); > + tcf_exts_change(tp, >exts, ); > > return 0; >+ errout: >+ tcf_exts_destroy(); >+ return err; > } > > static int mall_change(struct net *net, struct sk_buff *in_skb, >@@@ -162,39 -194,43 +167,44 @@@ > return -EINVAL; > } > > - f = kzalloc(sizeof(*f), GFP_KERNEL); > - if (!f) > + new = kzalloc(sizeof(*new), GFP_KERNEL); > + if (!new) > return -ENOBUFS; > >- tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); > - err = tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); >++ err = tcf_exts_init(>exts, TCA_MATCHALL_ACT, 0); >+ if (err) >+ goto err_exts_init; > > if (!handle) > handle = 1; > - f->handle = handle; > - f->flags = flags; > + new->handle = handle; > + new->flags = flags; > > - err = mall_set_parms(net, tp, f, base, tb, tca[TCA_RATE], ovr); > + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], ovr); > if (err) >- goto errout; >+ goto err_set_parms; > > if (tc_should_offload(dev, tp, flags)) { > - err = mall_replace_hw_filter(tp, f, (unsigned long) f); > + err = mall_replace_hw_filter(tp, new, (unsigned long) new); > if (err) { > if (tc_skip_sw(flags)) >- goto errout; >+ goto err_replace_hw_filter; > else > err = 0; > } > } > > - *arg = (unsigned long) f; > - rcu_assign_pointer(head->filter, f); > - > + *arg = (unsigned long) head; > + rcu_assign_pointer(tp->root, new); > + if (head) > + call_rcu(>rcu, mall_destroy_rcu); > return 0; > >- errout: >+ err_replace_hw_filter: >+ err_set_parms: > - tcf_exts_destroy(>exts); >++ tcf_exts_destroy(>exts); >+ err_exts_init: > - kfree(f); > + kfree(new); > return err; > } >