Skip to content

Commit

Permalink
net: microchip: sparx5: prevent uninitialized variable
Browse files Browse the repository at this point in the history
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: 23f8382 ("net: microchip: sparx5: add support for apptrust")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Nov 21, 2022
1 parent ef8c373 commit 62a45b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 62a45b3

Please sign in to comment.