Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cassini/sungem: limit reaches -1, but 0 tested

while (limit--)
if (test())
break;

if (limit <= 0)
goto test_failed;

In the last iteration, limit is decremented after the test to 0.
If just thereafter test() succeeds and a break occurs, the goto
still occurs because limit is 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Roel Kluin and committed by
David S. Miller
ff01b916 46578a69

+3 -3
+2 -2
drivers/net/cassini.c
··· 806 806 807 807 cas_phy_write(cp, MII_BMCR, BMCR_RESET); 808 808 udelay(100); 809 - while (limit--) { 809 + while (--limit) { 810 810 val = cas_phy_read(cp, MII_BMCR); 811 811 if ((val & BMCR_RESET) == 0) 812 812 break; ··· 979 979 writel(val, cp->regs + REG_PCS_MII_CTRL); 980 980 981 981 limit = STOP_TRIES; 982 - while (limit-- > 0) { 982 + while (--limit > 0) { 983 983 udelay(10); 984 984 if ((readl(cp->regs + REG_PCS_MII_CTRL) & 985 985 PCS_MII_RESET) == 0)
+1 -1
drivers/net/sungem_phy.c
··· 79 79 80 80 udelay(100); 81 81 82 - while (limit--) { 82 + while (--limit) { 83 83 val = __phy_read(phy, phy_id, MII_BMCR); 84 84 if ((val & BMCR_RESET) == 0) 85 85 break;