diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2021-09-17 14:36:31 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-09-19 13:23:47 +0100 |
commit | cbcca2e3961eac736566ac13ef0d0bf6f0b764ec (patch) | |
tree | a1638941e4d1d3acc7698f0e3ed5d1325ae1c77b /drivers/net | |
parent | 4fc29989835ab7379f807854b5f7338b752b9f1a (diff) |
net: phylink: don't call netif_carrier_off() with NULL netdev
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: f97493657c63 ("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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/phy/phylink.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0a0abe8e4be0..5a58c77d0002 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -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. |