diff options
author | Bruce Allan <bruce.w.allan@intel.com> | 2009-12-01 10:47:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-02 03:35:52 -0500 |
commit | eb656d4552a6c9de5fdcee4a376b171f57b8a4a2 (patch) | |
tree | e9b89b76b3bc1ca1347ce9051b007c16ee8ba81d /drivers/net/e1000e/phy.c | |
parent | caaddaf83501c79fe11b183c8972e60d8b7d5d56 (diff) |
e1000e: guard against buffer overflow in cable length tables
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000e/phy.c')
-rw-r--r-- | drivers/net/e1000e/phy.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c index 5cd01c691c53..9ce499734dca 100644 --- a/drivers/net/e1000e/phy.c +++ b/drivers/net/e1000e/phy.c | |||
@@ -44,6 +44,8 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, | |||
44 | /* Cable length tables */ | 44 | /* Cable length tables */ |
45 | static const u16 e1000_m88_cable_length_table[] = | 45 | static const u16 e1000_m88_cable_length_table[] = |
46 | { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; | 46 | { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; |
47 | #define M88E1000_CABLE_LENGTH_TABLE_SIZE \ | ||
48 | ARRAY_SIZE(e1000_m88_cable_length_table) | ||
47 | 49 | ||
48 | static const u16 e1000_igp_2_cable_length_table[] = | 50 | static const u16 e1000_igp_2_cable_length_table[] = |
49 | { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3, | 51 | { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3, |
@@ -1717,15 +1719,21 @@ s32 e1000e_get_cable_length_m88(struct e1000_hw *hw) | |||
1717 | 1719 | ||
1718 | ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); | 1720 | ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); |
1719 | if (ret_val) | 1721 | if (ret_val) |
1720 | return ret_val; | 1722 | goto out; |
1721 | 1723 | ||
1722 | index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> | 1724 | index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> |
1723 | M88E1000_PSSR_CABLE_LENGTH_SHIFT; | 1725 | M88E1000_PSSR_CABLE_LENGTH_SHIFT; |
1726 | if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) { | ||
1727 | ret_val = -E1000_ERR_PHY; | ||
1728 | goto out; | ||
1729 | } | ||
1730 | |||
1724 | phy->min_cable_length = e1000_m88_cable_length_table[index]; | 1731 | phy->min_cable_length = e1000_m88_cable_length_table[index]; |
1725 | phy->max_cable_length = e1000_m88_cable_length_table[index+1]; | 1732 | phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; |
1726 | 1733 | ||
1727 | phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; | 1734 | phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; |
1728 | 1735 | ||
1736 | out: | ||
1729 | return ret_val; | 1737 | return ret_val; |
1730 | } | 1738 | } |
1731 | 1739 | ||