aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-08-11 16:19:25 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-11 20:47:26 +0000
commitc276a80a4e52c065ed631e498ed2c3d284b45c75 (patch)
tree0a5100049ad3923c74da2349590af036ecb252a2
parente49cb7f757f6db8976b0d247e6a897eab5867634 (diff)
e1000: Check PHY control register reads
Do not modify a zero-initialized PHY control value when its preceding read failed. MFC after: 2 weeks
-rw-r--r--sys/dev/e1000/e1000_phy.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/dev/e1000/e1000_phy.c b/sys/dev/e1000/e1000_phy.c
index e3c8383d012e..8b00a80337a1 100644
--- a/sys/dev/e1000/e1000_phy.c
+++ b/sys/dev/e1000/e1000_phy.c
@@ -3541,10 +3541,15 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
**/
void e1000_power_up_phy_copper(struct e1000_hw *hw)
{
+ s32 ret_val;
u16 mii_reg = 0;
/* The PHY will retain its settings across a power down/up cycle */
- hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+ ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+ if (ret_val) {
+ DEBUGOUT("Error reading PHY control register\n");
+ return;
+ }
mii_reg &= ~MII_CR_POWER_DOWN;
hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
}
@@ -3559,10 +3564,15 @@ void e1000_power_up_phy_copper(struct e1000_hw *hw)
**/
void e1000_power_down_phy_copper(struct e1000_hw *hw)
{
+ s32 ret_val;
u16 mii_reg = 0;
/* The PHY will retain its settings across a power down/up cycle */
- hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+ ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+ if (ret_val) {
+ DEBUGOUT("Error reading PHY control register\n");
+ return;
+ }
mii_reg |= MII_CR_POWER_DOWN;
hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
msec_delay(1);
@@ -3889,7 +3899,11 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)
return E1000_SUCCESS;
/* Do not apply workaround if in PHY loopback bit 14 set */
- hw->phy.ops.read_reg(hw, PHY_CONTROL, &data);
+ ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &data);
+ if (ret_val) {
+ DEBUGOUT("Error reading PHY control register\n");
+ return ret_val;
+ }
if (data & PHY_CONTROL_LB)
return E1000_SUCCESS;