Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706277 > unrolled thread

[PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout

Started byColin King <colin.king@canonical.com>
First post2017-08-08 12:00 +0200
Last post2017-08-09 06:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout Colin King <colin.king@canonical.com> - 2017-08-08 12:00 +0200
    Re: [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned  wrap-around when decrementing timeout David Miller <davem@davemloft.net> - 2017-08-09 06:10 +0200

#1706277 — [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout

FromColin King <colin.king@canonical.com>
Date2017-08-08 12:00 +0200
Subject[PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout
Message-ID<uc9sS-6dC-23@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

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>
---
 drivers/net/phy/mdio-bcm-unimac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio-bcm-unimac.c b/drivers/net/phy/mdio-bcm-unimac.c
index 89425ca48412..73c5267a11fd 100644
--- a/drivers/net/phy/mdio-bcm-unimac.c
+++ b/drivers/net/phy/mdio-bcm-unimac.c
@@ -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;
-- 
2.11.0

[toc] | [next] | [standalone]


#1707043 — Re: [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout

FromDavid Miller <davem@davemloft.net>
Date2017-08-09 06:10 +0200
SubjectRe: [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout
Message-ID<ucqtH-1Fl-11@gated-at.bofh.it>
In reply to#1706277
From: Colin King <colin.king@canonical.com>
Date: Tue,  8 Aug 2017 10:52:32 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> 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>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web