diff mbox series

[net-next] net: microchip: sparx5: prevent uninitialized variable

Message ID Y3OQrGoFqvX2GkbJ@kili (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: microchip: sparx5: prevent uninitialized variable | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Dan Carpenter <error27@gmail.com>' != 'Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter Nov. 15, 2022, 1:14 p.m. UTC
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(-)

Comments

Daniel Machon Nov. 16, 2022, 7:09 a.m. UTC | #1
> 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>
Paolo Abeni Nov. 17, 2022, 3:03 p.m. UTC | #2
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
Dan Carpenter Nov. 17, 2022, 3:29 p.m. UTC | #3
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
diff mbox series

Patch

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++) {