lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1213141006-12593-1-git-send-email-tpiepho@freescale.com>
Date:	Tue, 10 Jun 2008 16:36:46 -0700
From:	Trent Piepho <tpiepho@...escale.com>
To:	netdev@...r.kernel.org
Cc:	Trent Piepho <tpiepho@...escale.com>
Subject: [PATCH] gianfar: Fix error in mdio reset timeout

The loop getting timed-out used "while (...  && timeout--)", which means
than when the timeout occurs, timeout will be -1 after the loop has exited.
Except timeout is unsigned, so it won't be negative!  The code that checks
if the looped exited because of a timeout used "if (timeout <= 0)", which
doesn't work, as (unsigned)-1 isn't <= 0.

Using "--timeout" in the loop fixes this problem.

This also fixes a bug in the existing code, where it will erroneously think
a timeout occurred if the condition the loop was waiting for was satisfied
on the final iteration before a timeout.

Signed-off-by: Trent Piepho <tpiepho@...escale.com>
---
 drivers/net/gianfar_mii.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index ebcfb27..906aba2 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -136,12 +136,12 @@ static int gfar_mdio_reset(struct mii_bus *bus)
 
 	/* Wait until the bus is free */
 	while ((gfar_read(&regs->miimind) & MIIMIND_BUSY) &&
-			timeout--)
+			--timeout)
 		cpu_relax();
 
 	mutex_unlock(&bus->mdio_lock);
 
-	if(timeout <= 0) {
+	if(timeout == 0) {
 		printk(KERN_ERR "%s: The MII Bus is stuck!\n",
 				bus->name);
 		return -EBUSY;
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ