From nobody Sun Apr 26 23:00:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C4E8C433EF for ; Tue, 21 Jun 2022 13:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349871AbiFUNvR (ORCPT ); Tue, 21 Jun 2022 09:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbiFUNvQ (ORCPT ); Tue, 21 Jun 2022 09:51:16 -0400 X-Greylist: delayed 110 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 21 Jun 2022 06:51:14 PDT Received: from mxout.security-mail.net (mxout.security-mail.net [85.31.212.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146D07661 for ; Tue, 21 Jun 2022 06:51:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id 8D5DE323714 for ; Tue, 21 Jun 2022 15:49:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1655819362; bh=78tnB+0PflHczeET28vWKLIRzZjUqx2ResLtP96u9HU=; h=From:To:Cc:Subject:Date; b=Mec2xBQSMOUYMNGg6sL/7x7BtpkedYPkRdTpn08t8kuybXVgoDi0yJJ46yFmkVV0+ KRezpafN9Un0QfoxnZ0RLMXt6CHrtmm6heYu5zuMcMznAK1h+D7LIlFEW5AdkMa375 x3I2hSD4Fomb4Ke7Yc1eNZly2E5on0qssnaRtTmU= Received: from fx303 (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id 62BB93236A7; Tue, 21 Jun 2022 15:49:21 +0200 (CEST) X-Virus-Scanned: E-securemail Secumail-id: Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx303.security-mail.net (Postfix) with ESMTPS id 6E93F3236D2; Tue, 21 Jun 2022 15:49:20 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 421C627E04D6; Tue, 21 Jun 2022 15:49:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 28A0527E04D7; Tue, 21 Jun 2022 15:49:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 28A0527E04D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1655819360; bh=Ho7qvdbzlGdpRQ3ww6//eS4KiQzS/QFvcZwfM5YeR+g=; h=From:To:Date:Message-Id; b=hWVI0oOcQeRRq7uUcTTn0UwsINQ6O0CrmGQsxc2U2fdgANSntuZ9huYrWxMf+UpGd KJjTpb9sOZM2UCKyRbB/uDZmNDBLBqmDktckrDcjISKYMATe1joAU8xqRxo7WxApzj wqBW51ZpXZCS8BwcHIkE2T3NMO7vWVG34Mjzd/I4= Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id q6HlZNV6A6jz; Tue, 21 Jun 2022 15:49:20 +0200 (CEST) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 0521E27E04D6; Tue, 21 Jun 2022 15:49:20 +0200 (CEST) From: Yann Sionneau To: linux-kernel@vger.kernel.org Cc: Russell King , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, jvetter@kalray.eu, jmaselbas@kalray.eu, Yann Sionneau Subject: [PATCH] net: phylink: check for pcs_ops being NULL Date: Tue, 21 Jun 2022 15:49:17 +0200 Message-Id: <20220621134917.24184-1-ysionneau@kalray.eu> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: by Secumail Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Out of tree drivers that have not been updated after 001f4261fe4d ("net: phylink: use legacy_pre_march2020") would not set= the legacy_pre_march2020 boolean which if not initialized will default to false. Such drivers will most likely still be using the legacy interface and will not have pcs_ops. Check for pcs_ops being NULL even if driver does not advertise itself as "pre march 2020 legacy". This commit adds a simple check instead of dereferencing a NULL pointer and prints an error message to indicate that the driver needs to be updated. Signed-off-by: Yann Sionneau --- drivers/net/phy/phylink.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 06943889d747..94abf418afb1 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -874,6 +874,14 @@ static int phylink_change_inband_advert(struct phylink= *pl) return 0; } =20 + if (unlikely(!pl->pcs_ops)) { + phylink_err(pl, "%s: Error, net driver needs to either be " + "updated to use pcs_ops or actually advertise it " + "has legacy interface by setting " + "legacy_pre_march2020 boolean", __func__); + return -EINVAL; + } + phylink_dbg(pl, "%s: mode=3D%s/%s adv=3D%*pb pause=3D%02x\n", __func__, phylink_an_mode_str(pl->cur_link_an_mode), phy_modes(pl->link_config.interface), --=20 2.17.1