netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable
@ 2022-11-15 13:14 Dan Carpenter
  2022-11-16  7:09 ` Daniel.Machon
  2022-11-17 15:03 ` Paolo Abeni
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-11-15 13:14 UTC (permalink / raw)
  To: David S. Miller, Daniel Machon
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lars Povlsen,
	Steen Hegelund, UNGLinuxDriver, netdev, kernel-janitors

Smatch complains that:

    drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c:112
    sparx5_dcb_apptrust_validate() error: uninitialized symbol 'match'.

This would only happen if the:

	if (sparx5_dcb_apptrust_policies[i].nselectors != nselectors)

condition is always true (they are not equal).  The "nselectors"
variable comes from dcbnl_ieee_set() and it is a number between 0-256.
This seems like a probably a real bug.

Fixes: 23f8382cd95d ("net: microchip: sparx5: add support for apptrust")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
index 8108f3767767..74abb946b2a3 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
@@ -90,7 +90,7 @@ static int sparx5_dcb_app_validate(struct net_device *dev,
 static int sparx5_dcb_apptrust_validate(struct net_device *dev, u8 *selectors,
 					int nselectors, int *err)
 {
-	bool match;
+	bool match = false;
 	int i, ii;
 
 	for (i = 0; i < ARRAY_SIZE(sparx5_dcb_apptrust_policies); i++) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable
  2022-11-15 13:14 [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable Dan Carpenter
@ 2022-11-16  7:09 ` Daniel.Machon
  2022-11-17 15:03 ` Paolo Abeni
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel.Machon @ 2022-11-16  7:09 UTC (permalink / raw)
  To: error27
  Cc: davem, edumazet, kuba, pabeni, Lars.Povlsen, Steen.Hegelund,
	UNGLinuxDriver, netdev, kernel-janitors

> Smatch complains that:
> 
>     drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c:112
>     sparx5_dcb_apptrust_validate() error: uninitialized symbol 'match'.
> 
> This would only happen if the:
> 
>         if (sparx5_dcb_apptrust_policies[i].nselectors != nselectors)
> 
> condition is always true (they are not equal).  The "nselectors"
> variable comes from dcbnl_ieee_set() and it is a number between 0-256.
> This seems like a probably a real bug.

That is indeed a bug.

Thank you, much appreciated.

> 
> Fixes: 23f8382cd95d ("net: microchip: sparx5: add support for apptrust")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
> index 8108f3767767..74abb946b2a3 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
> @@ -90,7 +90,7 @@ static int sparx5_dcb_app_validate(struct net_device *dev,
>  static int sparx5_dcb_apptrust_validate(struct net_device *dev, u8 *selectors,
>                                         int nselectors, int *err)
>  {
> -       bool match;
> +       bool match = false;
>         int i, ii;
> 
>         for (i = 0; i < ARRAY_SIZE(sparx5_dcb_apptrust_policies); i++) {
> --
> 2.35.1
>

Reviewed-by: Daniel Machon <daniel.machon@microchip.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable
  2022-11-15 13:14 [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable Dan Carpenter
  2022-11-16  7:09 ` Daniel.Machon
@ 2022-11-17 15:03 ` Paolo Abeni
  2022-11-17 15:29   ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2022-11-17 15:03 UTC (permalink / raw)
  To: Dan Carpenter, David S. Miller, Daniel Machon
  Cc: Eric Dumazet, Jakub Kicinski, Lars Povlsen, Steen Hegelund,
	UNGLinuxDriver, netdev, kernel-janitors

Hello,

On Tue, 2022-11-15 at 16:14 +0300, Dan Carpenter wrote:
> Smatch complains that:
> 
>     drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c:112
>     sparx5_dcb_apptrust_validate() error: uninitialized symbol 'match'.
> 
> This would only happen if the:
> 
> 	if (sparx5_dcb_apptrust_policies[i].nselectors != nselectors)
> 
> condition is always true (they are not equal).  The "nselectors"
> variable comes from dcbnl_ieee_set() and it is a number between 0-256.
> This seems like a probably a real bug.
> 
> Fixes: 23f8382cd95d ("net: microchip: sparx5: add support for apptrust")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

checkpatch complains about the From/SoB mismatch - 
'Dan Carpenter <error27@gmail.com>' vs 'Dan Carpenter
<dan.carpenter@oracle.com>'

Could you please send a v2 addressing that?

thanks!

Paolo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable
  2022-11-17 15:03 ` Paolo Abeni
@ 2022-11-17 15:29   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-11-17 15:29 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: David S. Miller, Daniel Machon, Eric Dumazet, Jakub Kicinski,
	Lars Povlsen, Steen Hegelund, UNGLinuxDriver, netdev,
	kernel-janitors

On Thu, Nov 17, 2022 at 04:03:07PM +0100, Paolo Abeni wrote:
> Hello,
> 
> On Tue, 2022-11-15 at 16:14 +0300, Dan Carpenter wrote:
> > Smatch complains that:
> > 
> >     drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c:112
> >     sparx5_dcb_apptrust_validate() error: uninitialized symbol 'match'.
> > 
> > This would only happen if the:
> > 
> > 	if (sparx5_dcb_apptrust_policies[i].nselectors != nselectors)
> > 
> > condition is always true (they are not equal).  The "nselectors"
> > variable comes from dcbnl_ieee_set() and it is a number between 0-256.
> > This seems like a probably a real bug.
> > 
> > Fixes: 23f8382cd95d ("net: microchip: sparx5: add support for apptrust")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> checkpatch complains about the From/SoB mismatch - 
> 'Dan Carpenter <error27@gmail.com>' vs 'Dan Carpenter
> <dan.carpenter@oracle.com>'
> 
> Could you please send a v2 addressing that?

Oops.  Sorry.  Resent.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-17 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 13:14 [PATCH net-next] net: microchip: sparx5: prevent uninitialized variable Dan Carpenter
2022-11-16  7:09 ` Daniel.Machon
2022-11-17 15:03 ` Paolo Abeni
2022-11-17 15:29   ` Dan Carpenter

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).