net: dsa: sja1105: Don't return a negative in u8 sja1105_stp_state_get
authorVladimir Oltean <olteanv@gmail.com>
Wed, 8 May 2019 20:32:25 +0000 (23:32 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 May 2019 20:57:50 +0000 (13:57 -0700)
Dan Carpenter says:

The patch 640f763f98c2: "net: dsa: sja1105: Add support for Spanning
Tree Protocol" from May 5, 2019, leads to the following static
checker warning:

        drivers/net/dsa/sja1105/sja1105_main.c:1073 sja1105_stp_state_get()
        warn: signedness bug returning '(-22)'

The caller doesn't check for negative errors anyway.

Fixes: 640f763f98c2: ("net: dsa: sja1105: Add support for Spanning Tree Protocol")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c

index 50ff625c85d678588b3a0d32e00796b035c953ca..0663b78a2f6cdf112ff1ec98b4344d1bd88f3343 100644 (file)
@@ -1070,7 +1070,11 @@ static u8 sja1105_stp_state_get(struct sja1105_private *priv, int port)
                return BR_STATE_LEARNING;
        if (mac[port].ingress && mac[port].egress && mac[port].dyn_learn)
                return BR_STATE_FORWARDING;
-       return -EINVAL;
+       /* This is really an error condition if the MAC was in none of the STP
+        * states above. But treating the port as disabled does nothing, which
+        * is adequate, and it also resets the MAC to a known state later on.
+        */
+       return BR_STATE_DISABLED;
 }
 
 /* For situations where we need to change a setting at runtime that is only