Skip to content

Commit

Permalink
net: qcom/emac: disable interrupts before calling phy_disconnect
Browse files Browse the repository at this point in the history
There is a race condition that can occur if EMAC interrupts are
enabled when phy_disconnect() is called.  phy_disconnect() sets
adjust_link to NULL.  When an interrupt occurs, the ISR might
call phy_mac_interrupt(), which wakes up the workqueue function
phy_state_machine().  This function might reference adjust_link,
thereby causing a null pointer exception.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Timur Tabi authored and David S. Miller committed Oct 15, 2016
1 parent f007643 commit 93966b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/qualcomm/emac/emac-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,14 +1021,18 @@ void emac_mac_down(struct emac_adapter *adpt)
napi_disable(&adpt->rx_q.napi);

phy_stop(adpt->phydev);
phy_disconnect(adpt->phydev);

/* disable mac irq */
/* Interrupts must be disabled before the PHY is disconnected, to
* avoid a race condition where adjust_link is null when we get
* an interrupt.
*/
writel(DIS_INT, adpt->base + EMAC_INT_STATUS);
writel(0, adpt->base + EMAC_INT_MASK);
synchronize_irq(adpt->irq.irq);
free_irq(adpt->irq.irq, &adpt->irq);

phy_disconnect(adpt->phydev);

emac_mac_reset(adpt);

emac_tx_q_descs_free(adpt);
Expand Down

0 comments on commit 93966b7

Please sign in to comment.