From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB24C433FE for ; Mon, 15 Nov 2021 23:37:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 295C461B53 for ; Mon, 15 Nov 2021 23:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353779AbhKOXkF (ORCPT ); Mon, 15 Nov 2021 18:40:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:44610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343679AbhKOTVg (ORCPT ); Mon, 15 Nov 2021 14:21:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 17A3B63574; Mon, 15 Nov 2021 18:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637001862; bh=CBkFCTb5fZ55E+dx7DYJF8WEckb1MR7O8bN1kEYFPLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGM+DGojNfYC+VbpSvkcswlcHK3KoXMzMZaY3EmqxqB0bFQ+8xiBzQovdO8/1MPRj SvrEkeOU1o1zTJSSn464//vN8f5y75DHdrX23gyunmVyppJTnuR8AiIsaVmbjTiYIb UCcGMBJxZZn3MGLaep8Tj9Rb8dbmVSa/3dYCug6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "Russell King (Oracle)" , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 342/917] net: phylink: dont call netif_carrier_off() with NULL netdev Date: Mon, 15 Nov 2021 17:57:17 +0100 Message-Id: <20211115165440.346950122@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165428.722074685@linuxfoundation.org> References: <20211115165428.722074685@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King (Oracle) [ 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 --- 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 0a0abe8e4be0b..5a58c77d00022 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. -- 2.33.0