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: 13799133 X-Patchwork-Delegate: kuba@kernel.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9715517A584; Tue, 10 Sep 2024 17:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725990406; cv=none; b=PSMI3Hf0lUgK/sTykrU4FheVLiLvTmL6MJO+Ttv0f+Fn8Gdd+FPUdPSFU8nMQ2eRJ7YypNmVuyGihcLRE2LRGG+Sdpe0LI1qQX2n4LB3Awr3+TRWY3FKcRWlM2ItJFDoWAJl+qPV7NDydnWOuR4Fms8xPgrXr2NdQKimVr1wcQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725990406; c=relaxed/simple; bh=5L170aaHaiQNUXme2FCcDwY0Y4/sk8V/9v31nUfkAig=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iuLrk6G9/7rU+8ItAk0zHZ9YkKCVOOt/JmtbLjO7kEKs7+PyQukdKq+yX5PloMOvBr0JQX89uDHr9rIrDaeU6s6out5wWyiNtYHUB8JsNv9tFJ2Q2U7ZQYqmXILB5cCvzsMZw3N8pu7djKFGDnE/AtuXN8rPhRhH6eLdvKKRU2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GRdtsHyj; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GRdtsHyj" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-Patchwork-Delegate: kuba@kernel.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);