Skip to contentSkip to conversation

bcm63xx_enet: timeout off by one in do_mdio_op()

PATCH Applied Roel Kluin 3 participants 3 messages Sep 21, 2009 – Oct 1, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 bcm63xx_enet: timeout off by one in do_mdio_op()

`while (limit-- >= 0)' reaches -2 after the loop upon timeout.

---
Small chance to occur, probably.

drivers/net/bcm63xx_enet.c +1 -1
index 09d2709..ba29dc3 100644
@@ -90,7 +90,7 @@ static int do_mdio_op(struct bcm_enet_priv *priv, unsigned int data)
 		if (enet_readl(priv, ENET_IR_REG) & ENET_IR_MII)
 			break;
 		udelay(1);
-	} while (limit-- >= 0);
+	} while (limit-- > 0);
 
 	return (limit < 0) ? 1 : 0;
 }
Acked-by on v1 1/1
#1 lore raw

On Mon, 2009-09-21 at 22:08 +0200, Roel Kluin wrote:

Hi Roel,

Quoted 1 line

`while (limit-- >= 0)' reaches -2 after the loop upon timeout.

The 1000us limit was chosen arbitrarily, since mdio access are much shorter, and was just to prevent CPU lockup in case of hardware bug.

But it looks like a bug, and since you're the second one reporting this, this should be fixed :)

Quoted 1 line
Quoted 16 lines

---
Small chance to occur, probably.

drivers/net/bcm63xx_enet.c +1 -1
index 09d2709..ba29dc3 100644
@@ -90,7 +90,7 @@ static int do_mdio_op(struct bcm_enet_priv *priv, unsigned int data)
 		if (enet_readl(priv, ENET_IR_REG) & ENET_IR_MII)
 			break;
 		udelay(1);
-	} while (limit-- >= 0);
+	} while (limit-- > 0);
 
 	return (limit < 0) ? 1 : 0;
 }
Signature · 1 line
Maxime
maintainer Applied
#2 lore raw

From: Maxime Bizon <[email protected]>
Date: Wed, 30 Sep 2009 16:01:28 +0200

Quoted 10 lines · Roel Kluin

Hi Roel,

Quoted 1 line

`while (limit-- >= 0)' reaches -2 after the loop upon timeout.

The 1000us limit was chosen arbitrarily, since mdio access are much shorter, and was just to prevent CPU lockup in case of hardware bug.

Quoted 7 lines

But it looks like a bug, and since you're the second one reporting this, this should be fixed :)

Quoted 1 line

Applied, thanks.