From patchwork Tue Sep 10 17:46:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13799136 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CBBEEDE9AC for ; Tue, 10 Sep 2024 17:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=8sAeKFMvf+x+ARyRCKEDkQ7ZaGz+Oq5cUgRnc95/j5A=; b=MrRr7WbdMKpSVzfQb06lYSTOiP F2QY1927AEXpk/3rpbb3HkdVOl3zcuzYKRvk6C2Kaus8W6VFFg6+BE7wsxPl5W68wWeD2aVgwAw+9 AZyLLYLwEw8MNS2ddQ+3eH0ogqU5BvuShWalNj5O/UkoROwGfsW9Kdn4oHTTSC2gMkXanS92p5Njn dwmPnpZKYOwpsVz/vPKk8NS/B6zqOPNJrrsSUqFp+bzo1rYLGQ73RRdhW3RY9o5h7rorz27NRNUFQ UwcE4GUAOxchTwvoprviu4dDLsWLZH+JwRdj8+PMMRf2XVg+Nnmdxr2SwTJHXcUydKDzSXObW3OyI EB3XAeNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so4xw-00000006eCs-3dSu; Tue, 10 Sep 2024 17:47:48 +0000 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so4wu-00000006e2V-1Cep for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 17:46:46 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1C636240002; Tue, 10 Sep 2024 17:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1725990401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8sAeKFMvf+x+ARyRCKEDkQ7ZaGz+Oq5cUgRnc95/j5A=; b=GRdtsHyjEH3bI0d3aPr59ZEiQiSxkTJYM+0ImIKIB/7ijfXJ3B8SP6dhQOIV/iup1+oIPO zsomKahS3syUfvJC9/X+zWIct9rItKyTddzT2qm59GRselbaRRJBQyI1xQVl48fMYTWurQ CmpgTqrbagiPakeFD0shlymmJOOW3hAydAbIYaVIhVnPAVem3C//+02x5apohDUA88lJFb qifDxM6JDf+uMBnmqrSZ2uf+Zu47BpUDWkd2qThAPo9bv1DIprGlupq7YbrQtdTOMPp7d8 DetljiY/dm8BlHTdyx0qYAOaPgUIrQ6IF7m3XRjWRVHxuEqdVU3706qQPblc4Q== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Jesse Brandeburg , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart , Marc Kleine-Budde , Dan Carpenter , Romain Gantois Subject: [PATCH net-next] net: ethtool: phy: Check the req_info.pdn field for GET commands Date: Tue, 10 Sep 2024 19:46:35 +0200 Message-ID: <20240910174636.857352-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_104644_786705_D98AA3ED X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When processing the netlink GET requests to get PHY info, the req_info.pdn pointer is NULL when no PHY matches the requested parameters, such as when the phy_index is invalid, or there's simply no PHY attached to the interface. Therefore, check the req_info.pdn pointer for NULL instead of dereferencing it. Suggested-by: Eric Dumazet Reported-by: Eric Dumazet Closes: https://lore.kernel.org/netdev/CANn89iKRW0WpGAh1tKqY345D8WkYCPm3Y9ym--Si42JZrQAu1g@mail.gmail.com/T/#mfced87d607d18ea32b3b4934dfa18d7b36669285 Fixes: 17194be4c8e1 ("net: ethtool: Introduce a command to list PHYs on an interface") Signed-off-by: Maxime Chevallier Reviewed-by: Eric Dumazet --- Hi, I'm targetting net-next as the commit this patch fixes is still in net-next. net/ethtool/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c index 560dd039c662..4ef7c6e32d10 100644 --- a/net/ethtool/phy.c +++ b/net/ethtool/phy.c @@ -164,7 +164,7 @@ int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info) goto err_unlock_rtnl; /* No PHY, return early */ - if (!req_info.pdn->phy) + if (!req_info.pdn) goto err_unlock_rtnl; ret = ethnl_phy_reply_size(&req_info.base, info->extack);