Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61217be

Browse files
zhangyuedavem330
authored andcommitted
net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound
In line 5001, if all id in the array 'lp->phy[8]' is not 0, when the 'for' end, the 'k' is 8. At this time, the array 'lp->phy[8]' may be out of bound. Signed-off-by: zhangyue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e5d212 commit 61217be

File tree

1 file changed

+17
-13
lines changed
  • drivers/net/ethernet/dec/tulip

1 file changed

+17
-13
lines changed

drivers/net/ethernet/dec/tulip/de4x5.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,19 +5000,23 @@ mii_get_phy(struct net_device *dev)
50005000
}
50015001
if ((j == limit) && (i < DE4X5_MAX_MII)) {
50025002
for (k=0; k < DE4X5_MAX_PHY && lp->phy[k].id; k++);
5003-
lp->phy[k].addr = i;
5004-
lp->phy[k].id = id;
5005-
lp->phy[k].spd.reg = GENERIC_REG; /* ANLPA register */
5006-
lp->phy[k].spd.mask = GENERIC_MASK; /* 100Mb/s technologies */
5007-
lp->phy[k].spd.value = GENERIC_VALUE; /* TX & T4, H/F Duplex */
5008-
lp->mii_cnt++;
5009-
lp->active++;
5010-
printk("%s: Using generic MII device control. If the board doesn't operate,\nplease mail the following dump to the author:\n", dev->name);
5011-
j = de4x5_debug;
5012-
de4x5_debug |= DEBUG_MII;
5013-
de4x5_dbg_mii(dev, k);
5014-
de4x5_debug = j;
5015-
printk("\n");
5003+
if (k < DE4X5_MAX_PHY) {
5004+
lp->phy[k].addr = i;
5005+
lp->phy[k].id = id;
5006+
lp->phy[k].spd.reg = GENERIC_REG; /* ANLPA register */
5007+
lp->phy[k].spd.mask = GENERIC_MASK; /* 100Mb/s technologies */
5008+
lp->phy[k].spd.value = GENERIC_VALUE; /* TX & T4, H/F Duplex */
5009+
lp->mii_cnt++;
5010+
lp->active++;
5011+
printk("%s: Using generic MII device control. If the board doesn't operate,\nplease mail the following dump to the author:\n", dev->name);
5012+
j = de4x5_debug;
5013+
de4x5_debug |= DEBUG_MII;
5014+
de4x5_dbg_mii(dev, k);
5015+
de4x5_debug = j;
5016+
printk("\n");
5017+
} else {
5018+
goto purgatory;
5019+
}
50165020
}
50175021
}
50185022
purgatory:

0 commit comments

Comments
 (0)