Skip to content

Commit

Permalink
net: phylink: don't call netif_carrier_off() with NULL netdev
Browse files Browse the repository at this point in the history
Dan Carpenter points out that we have a code path that permits a NULL
netdev pointer to be passed to netif_carrier_off(), which will cause
a kernel oops. In any case, we need to set pl->old_link_state to false
to have the desired effect when there is no netdev present.

Fixes: f974936 ("net: phylink: add suspend/resume support")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Russell King (Oracle) authored and David S. Miller committed Sep 19, 2021
1 parent 4fc2998 commit cbcca2e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/phy/phylink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,10 @@ void phylink_suspend(struct phylink *pl, bool mac_wol)
* but one would hope all packets have been sent. This
* also means phylink_resolve() will do nothing.
*/
netif_carrier_off(pl->netdev);
if (pl->netdev)
netif_carrier_off(pl->netdev);
else
pl->old_link_state = false;

/* We do not call mac_link_down() here as we want the
* link to remain up to receive the WoL packets.
Expand Down

0 comments on commit cbcca2e

Please sign in to comment.