Commit 5425711b authored by Colin Ian King's avatar Colin Ian King Committed by David S. Miller

net: dsa: sja1105: fix check on while loop exit

The while-loop exit condition check is not correct; the
loop should continue if the returns from the function calls are
negative or the CRC status returns are invalid.  Currently it
is ignoring the returns from the function calls.  Fix this by
removing the status return checks and only break from the loop
at the very end when we know that all the success condtions have
been met.

Kudos to Dan Carpenter for describing the correct fix and
Vladimir Oltean for noting the change to the check on the number
of retries.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 8aa9ebcc ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Tested-by: default avatarVladimir Oltean <olteanv@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 86dc59e3
...@@ -466,14 +466,15 @@ int sja1105_static_config_upload(struct sja1105_private *priv) ...@@ -466,14 +466,15 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
"invalid, retrying...\n"); "invalid, retrying...\n");
continue; continue;
} }
} while (--retries && (status.crcchkl == 1 || status.crcchkg == 1 || /* Success! */
status.configs == 0 || status.ids == 1)); break;
} while (--retries);
if (!retries) { if (!retries) {
rc = -EIO; rc = -EIO;
dev_err(dev, "Failed to upload config to device, giving up\n"); dev_err(dev, "Failed to upload config to device, giving up\n");
goto out; goto out;
} else if (retries != RETRIES - 1) { } else if (retries != RETRIES) {
dev_info(dev, "Succeeded after %d tried\n", RETRIES - retries); dev_info(dev, "Succeeded after %d tried\n", RETRIES - retries);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment