diff mbox

fealnx: Write outside array bounds

Message ID 4A6B43B8.3070209@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

roel kluin July 25, 2009, 5:41 p.m. UTC
phy_idx is checked to be < 4, but np->phys[] is 2 elements long

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---

>> Or should the number of elements be increased?

>> -		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
>> +		for (phy = 1; phy < 32 && phy_idx < 2; phy++) {

> In either of the case, one should use ARRAY_SIZE(np->phys) instead of the 
> number.

Ah, yes.

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

Comments

David Miller July 27, 2009, 2:01 a.m. UTC | #1
From: Roel Kluin <roel.kluin@gmail.com>
Date: Sat, 25 Jul 2009 19:41:12 +0200

> phy_idx is checked to be < 4, but np->phys[] is 2 elements long
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

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

Patch

diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 48385c4..160655d 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -584,7 +584,8 @@  static int __devinit fealnx_init_one(struct pci_dev *pdev,
 	if (np->flags == HAS_MII_XCVR) {
 		int phy, phy_idx = 0;
 
-		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
+		for (phy = 1; phy < 32 && phy_idx < ARRAY_SIZE(np->phys);
+			       phy++) {
 			int mii_status = mdio_read(dev, phy, 1);
 
 			if (mii_status != 0xffff && mii_status != 0x0000) {