Skip to contentSkip to conversation

net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout

PATCH New Andrew Lunn 1 participant 1 message Aug 8, 2017

Subsystems (3)
lore
Share & tools
lore

Andrew Lunn

author maintainer
#0 lore raw

PATCH 1/1 net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout

----- Forwarded message from Colin King <[email protected]> -----

Date: Tue, 8 Aug 2017 10:52:32 +0100
From: Colin King <[email protected]>
To: Andrew Lunn <[email protected]>, Florian Fainelli <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout
X-Spam-Status: No, score=-7.4 required=4.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD,T_HEADER_FROM_DIFFERENT_DOMAINS autolearn=ham
autolearn_force=no version=3.4.0

From: Colin Ian King <[email protected]>

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")
---
 drivers/net/phy/mdio-bcm-unimac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio-bcm-unimac.c +1 -1
index 89425ca48412..73c5267a11fd 100644
@@ -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;
Signature · 13 lines
2.11.0


----- End forwarded message -----

Hi Florian

You might want to look at bcm_sf2_cfp_op() and bcm_sf2_cfp_rst().

Colin, do you have more of these patches? Have you done a tree wide
search?

       Andrew