Skip to content

Commit fbb2d80

Browse files
gobenjigregkh
authored andcommitted
e1000e: Fix error path in link detection
commit c4c40e51f9c32c6dd8adf606624c930a1c4d9bbb upstream. In case of error from e1e_rphy(), the loop will exit early and "success" will be set to true erroneously. Signed-off-by: Benjamin Poirier <bpoirier@suse.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d6968bc commit fbb2d80

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • drivers/net/ethernet/intel/e1000e

drivers/net/ethernet/intel/e1000e/phy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,7 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
17441744
s32 ret_val = 0;
17451745
u16 i, phy_status;
17461746

1747+
*success = false;
17471748
for (i = 0; i < iterations; i++) {
17481749
/* Some PHYs require the MII_BMSR register to be read
17491750
* twice due to the link bit being sticky. No harm doing
@@ -1763,16 +1764,16 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
17631764
ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
17641765
if (ret_val)
17651766
break;
1766-
if (phy_status & BMSR_LSTATUS)
1767+
if (phy_status & BMSR_LSTATUS) {
1768+
*success = true;
17671769
break;
1770+
}
17681771
if (usec_interval >= 1000)
17691772
msleep(usec_interval / 1000);
17701773
else
17711774
udelay(usec_interval);
17721775
}
17731776

1774-
*success = (i < iterations);
1775-
17761777
return ret_val;
17771778
}
17781779

0 commit comments

Comments
 (0)