net: phy: vitesse: Fix incorrect test for timeout
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Wed, 6 Aug 2025 09:37:26 +0000 (10:37 +0100)
committerJerome Forissier <jerome.forissier@linaro.org>
Mon, 18 Aug 2025 12:08:57 +0000 (14:08 +0200)
In vsc8514_config there is a while loop for detecting a config failure
using a timeout counter with a post-decrement. In the case of a timeout
this will result in the loop exiting with timeout == -1 so use that as
the test below the loop to detect that the timeout occurred.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
drivers/net/phy/vitesse.c

index 4867d19..821d387 100644 (file)
@@ -239,7 +239,7 @@ static int vsc8514_config(struct phy_device *phydev)
        while ((val & MIIM_VSC8514_18G_CMDSTAT) && timeout--)
                val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_GENERAL18);
 
-       if (0 == timeout) {
+       if (timeout == -1) {
                printf("PHY 8514 config failed\n");
                return -1;
        }