lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.14 351/849] net: phylink: dont call netif_carrier_off() with NULL netdev
    Date
    From: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

    [ 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 | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
    index 0d3d9c3ee83c8..6e96d7b7ee445 100644
    --- a/drivers/net/phy/phylink.c
    +++ b/drivers/net/phy/phylink.c
    @@ -1332,7 +1332,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.
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-11-16 02:37    [W:5.296 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site