From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbdHHJwf (ORCPT ); Tue, 8 Aug 2017 05:52:35 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45162 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbdHHJwe (ORCPT ); Tue, 8 Aug 2017 05:52:34 -0400 From: Colin King To: Andrew Lunn , Florian Fainelli , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] net: phy: mdio-bcm-unimac: fix unsigned wrap-around when decrementing timeout Date: Tue, 8 Aug 2017 10:52:32 +0100 Message-Id: <20170808095232.13490-1-colin.king@canonical.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King 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 --- 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