OSDN Git Service

net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout
authorColin Ian King <colin.king@canonical.com>
Tue, 8 Aug 2017 09:52:32 +0000 (10:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Aug 2017 04:07:41 +0000 (21:07 -0700)
Change post-decrement compare to pre-decrement to avoid an
unsigned integer wrap-around on timeout. This leads to the following
!timeout check to never to be true so -ETIMEDOUT is never returned.

Detected by CoverityScan, CID#1452623 ("Logically dead code")

Fixes: 69a60b0579a4 ("net: phy: mdio-bcm-unimac: factor busy polling loop")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio-bcm-unimac.c

index 89425ca..73c5267 100644 (file)
@@ -71,7 +71,7 @@ static int unimac_mdio_poll(void *wait_func_data)
                        return 0;
 
                usleep_range(1000, 2000);
-       } while (timeout--);
+       } while (--timeout);
 
        if (!timeout)
                return -ETIMEDOUT;