e1000e: Fix link check race condition
authorBenjamin Poirier <[email protected]>
Tue, 6 Mar 2018 01:55:53 +0000 (10:55 +0900)
committerJeff Kirsher <[email protected]>
Mon, 12 Mar 2018 19:05:39 +0000 (12:05 -0700)
commite2710dbf0dc1e37d85368e2404049dadda848d5a
treef1b121b8473f89e4c6abfa94fe6e443f165a47f5
parent3016e0a0c91246e55418825ba9aae271be267522
e1000e: Fix link check race condition

Alex reported the following race condition:

/* link goes up... interrupt... schedule watchdog */
\ e1000_watchdog_task
\ e1000e_has_link
\ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link
\ e1000e_phy_has_link_generic(..., &link)
link = true

 /* link goes down... interrupt */
 \ e1000_msix_other
 hw->mac.get_link_status = true

/* link is up */
mac->get_link_status = false

link_active = true
/* link_active is true, wrongly, and stays so because
 * get_link_status is false */

Avoid this problem by making sure that we don't set get_link_status = false
after having checked the link.

It seems this problem has been present since the introduction of e1000e.

Link: https://lkml.org/lkml/2018/1/29/338
Reported-by: Alexander Duyck <[email protected]>
Signed-off-by: Benjamin Poirier <[email protected]>
Acked-by: Alexander Duyck <[email protected]>
Tested-by: Aaron Brown <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
drivers/net/ethernet/intel/e1000e/ich8lan.c
drivers/net/ethernet/intel/e1000e/mac.c