fealnx: Write outside array bounds
Subsystems (2)
PATCH 1/1 fealnx: Write outside array bounds
phy_idx is checked to be < 4, but np->phys[] is 2 elements long
---
Or should the number of elements be increased?
drivers/net/fealnx.c +1 -1
@@ -584,7 +584,7 @@ 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 <2 ; phy++) {int mii_status =mdio_read (dev, phy,1 );if (mii_status !=0xffff && mii_status !=0x0000 ) {
Quoted 11 lines · Roel Kluin
phy_idxis checked to be < 4, but np->phys[] is 2 elements longSigned-off-by Roel Kluin <[email protected]>---
Or should the number of elements be increased?drivers/net/fealnx.c +0
-0
drivers/net/fealnx.c static int __devinit fealnx_init_one(struct pci_dev *pdev, · line 590
Quoted 8 lines
drivers/net/fealnx.c +1
-1@@ -584,7 +584,7 @@ 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 <2 ; phy++) {int mii_status =mdio_read (dev, phy,1 );if (mii_status !=0xffff && mii_status !=0x0000 ) {
In either of the case, one should use ARRAY_SIZE(np->phys) instead of the number.
Signature · 1 line
i.
phy_idx is checked to be < 4, but np->phys[] is 2 elements long
---
Quoted 7 lines
Review
Quoted 4 lines
Or should the number of elements be increased?
(quoted diff) +1
-1- 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.
drivers/net/fealnx.c +2 -1
@@ -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 ) {
From: Roel Kluin <[email protected]>
Date: Sat, 25 Jul 2009 19:41:12 +0200
Quoted 3 lines
phy_idxis checked to be < 4, but np->phys[] is 2 elements longSigned-off-by Roel Kluin <[email protected]>
Applied.