From: Russell King (Oracle) Date: Fri, 17 Sep 2021 13:36:31 +0000 (+0100) Subject: net: phylink: don't call netif_carrier_off() with NULL netdev X-Git-Tag: accepted/tizen/unified/20230118.172025~5722 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a1028f896465d19d26f93fe16e6b4a0b5ba903b;p=platform%2Fkernel%2Flinux-rpi.git net: phylink: don't call netif_carrier_off() with NULL netdev [ Upstream commit cbcca2e3961eac736566ac13ef0d0bf6f0b764ec ] 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 Signed-off-by: Russell King (Oracle) Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0a0abe8..5a58c77 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.