net: phylink: don't call netif_carrier_off() with NULL netdev
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 17 Sep 2021 13:36:31 +0000 (14:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:24 +0000 (19:16 +0100)
commit1a1028f896465d19d26f93fe16e6b4a0b5ba903b
tree9fbacd13ed23e6948f8fe2f4829a3c53fa3431d6
parent02113c83f405c37896d57856a7e1d2fc492e7d36
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 <dan.carpenter@oracle.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/phylink.c