Article View: linux.kernel.netdev
Article #6609Re: [PATCH net v4] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
From: netdev-bot+sashiko
Date: Thu, 22 Oct 2026 20:16
Date: Thu, 22 Oct 2026 20:16
147 lines
12691 bytes
12691 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch turns off every WoL mode on PHY-less (fixed-link)
LAN7801 devices.
- [Medium] On a PHY-less LAN7801, ethtool is told WoL is off while system
suspend still arms magic-packet wake, and the user cannot turn it off…
--
net: usb: lan78xx: avoid NULL PHY dereference in WoL setup
This patch fixes a NULL netdev->phydev dereference in lan78xx_set_wol()
on LAN7801 fixed-link setups that have no attached PHY. When no PHY is
attached, lan78xx_get_wol() now reports no WoL capabilities, and
lan78xx_set_wol() returns -EOPNOTSUPP before it changes the wakeup
configuration.
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 5655941f14783..4f100bec5b3ae 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1764,6 +1764,12 @@ static void lan78xx_get_wol(struct net_device *netdev,
> u32 buf;
> struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0]);
>
> + if (!netdev->phydev) {
> + wol->supported = 0;
> + wol->wolopts = 0;
> + return;
> + }
> +
[Severity: Medium]
Does this turn off more WoL modes than it needs to on a PHY-less LAN7801?
In lan78xx_set_suspend(), only WAKE_PHY involves the PHY:
drivers/net/usb/lan78xx.c:lan78xx_set_suspend() {
...
if (wol & WAKE_PHY) {
temp_pmt_ctl |= PMT_CTL_PHY_WAKE_EN_;
...
if (wol & WAKE_MAGIC) {
temp_wucsr |= WUCSR_MPEN_;
...
if (wol & WAKE_BCAST) {
temp_wucsr |= WUCSR_BCST_EN_;
...
}
WAKE_MAGIC, WAKE_BCAST, WAKE_MCAST, WAKE_UCAST and WAKE_ARP are set up
only through MAC registers (WUCSR, WUF_CFG/WUF_MASK, PMT_CTL).
With supported = 0 here, ethtool_set_wol() rejects any nonzero wolopts
with -EINVAL. lan78xx_set_wol() below also returns -EOPNOTSUPP. So
fixed-link users can no longer set up magic, broadcast, multicast,
unicast or ARP wake.
Before e110bc825897, lan78xx_register_fixed_phy() gave a PHY-less
LAN7801 a fixed PHY, so phydev was never NULL. get_wol reported
WAKE_ALL. set_wol stored pdata->wol and called
device_set_wakeup_enable() before phy_ethtool_set_wol() returned
-EOPNOTSUPP. In that setup the MAC-level setting still reached the
suspend path.
The commit message says:
With this change, the PHY-less configuration no longer
advertises unsupported WoL operations, avoiding the crash.
Are the MAC-only modes actually unsupported here?
Would it work to skip only phy_ethtool_set_wol() when phydev is NULL,
and advertise WAKE_ALL & ~WAKE_PHY? That would avoid the NULL
dereference and keep MAC WoL. If dropping MAC WoL is intended, could
the commit message say so?
> if (usb_autopm_get_interface(dev->intf) < 0)
> return;
>
> @@ -1795,6 +1801,9 @@ static int lan78xx_set_wol(struct net_device *netdev,
> if (wol->wolopts & ~WAKE_ALL)
> return -EINVAL;
>
> + if (!netdev->phydev)
> + return -EOPNOTSUPP;
> +
[Severity: Medium]
Can this leave magic-packet wake armed while ethtool reports WoL as
off?
lan78xx_bind() sets this default whether or not a PHY exists:
pdata->wol = WAKE_MAGIC;
lan78xx_probe() enables USB wakeup unconditionally:
ret = device_set_wakeup_enable(&udev->dev, true);
On system suspend with the interface up, lan78xx_suspend() still uses
pdata->wol:
ret = lan78xx_set_suspend(dev, pdata->wol);
For WAKE_MAGIC this sets WUCSR_MPEN_, PMT_CTL_WOL_EN_ and
PMT_CTL_SUS_MODE_3_. These are all MAC registers, so the wake source is
armed even without a PHY.
Meanwhile, lan78xx_get_wol() now reports wolopts = 0 when there is no
PHY. Running "ethtool -s <dev> wol d" sends wolopts = 0. That matches
the reported value, so ethtool_set_wol() returns early:
net/ethtool/ioctl.c:ethtool_set_wol() {
...
if (wol.wolopts == cur_wol.wolopts &&
!memcmp(wol.sopass, cur_wol.sopass, sizeof(wol.sopass)))
return 0;
...
}
Even if the driver were called, this early -EOPNOTSUPP returns before
pdata->wol or device_set_wakeup_enable() is updated.
Before the patch, get_wol reported wolopts = pdata->wol with
supported = WAKE_ALL, so ethtool showed what suspend would arm.
Should the PHY-less case also clear pdata->wol and the default udev
wakeup? Or should the MAC-only modes keep working, with only WAKE_PHY
rejected?
> ret = usb_autopm_get_interface(dev->intf);
> if (ret < 0)
> return ret;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020201537.2465655-1-prashantsengar25031%40gmail.com
Technical Details
Message-ID:
<179270019104.1189532.4796247224411917544@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350804-linux-kernel-netdev=dewy.ruReferences:
<20261020201537.2465655-1-prashantsengar25031@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350804-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4] net: usb: lan78xx: avoid NULL PHY dereference in WoL setup Date: Thu, 22 Oct 2026 20:16:31 +0000 Organization: Usenet Network Message-ID: <179270019104.1189532.4796247224411917544@kernel.org> References: <20261020201537.2465655-1-prashantsengar25031@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="322553"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zwYT6b4SYO8rIqkacqZToY6NAVM= sha256:SmiAMWsLZB917YCO3rb6+OdrpdtzmYfDHoMVQurdALo= sha1:4VyelLUswfNXVmu6naCiZLtdbWk= sha256:70SW8be1tWIxUoPn01eK1jLRWrFKA2PW2ArB+ieR6ec= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 545EB11136C; Thu, 22 Oct 2026 23:27:34 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.639 X-Spam-Status: No, score=-2.639 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x8VVWGBGAYRd; Thu, 22 Oct 2026 23:27:26 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350804-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id C7C5F11110F; Thu, 22 Oct 2026 23:27:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E8D8364A6C; Thu, 22 Oct 2026 20:17:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792700193; b=qpE8/9CW1t1JOSpl9X6Ixt5obxYyrtOgm+y2hamU/jfUlMbk4jsT+tLjIAX1qmV/ZrVM yKiYqq3j4psYPLFq9+cpp3tfCXA+obScd7mCahxwWv4/5JlwYRFYmiDfra0dvwQ/1uPGD Vmz+N5qloZejhhG+4kL+jhEXi+fxFXl+5IJzUk3wYOtJ0Jm8DBrTa77+V0AjgmzaXf7U+ T4Uv2mjt86ojaPd1fvwuLE6J7v9cQk7Xd1t6tLdH9fg2o95HOpQpwWjPR6x9dBAipXdBp V+zvZ0+8VSphKvrAN6wRDlGgT3qxFNEsXVPUvhC1kdWsbZp6TiWJs01rJKJyGnReR5g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792700193; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=tnLblktMeZ7lb0jeukkbTTUSpbE1oL5D1vptFoQWo3Q=; b=P20ERi5AXUEE5gxa8qNEiiUrX71tAIf9hk9El0n10C/6pHvjlAptIL4jSXPE7fbAalFN UfDLso+GjZ7d1bk7YCCxq7AF61ALuGbCE8HUfWhFZJ3yeQbWZHw+YlNrBw7nns7S5yNXU +JTRcssJxEVyHCRzNpwtuOfAWYRE9ZWF2+eB0zpCTYZuillL9AKtCScw3HsRW8Ok3JwhU jdJdQL9SPr8tXEUshsqqPn1oeT156nPV3+E+dzPzT3tfFpwr2ztSAkgtNdEbO9AN83Cj0 2K3MWZv8IEZk8bCGvmYN+bRcLOtQnMibqZ5nNJV9CaDcpVrYSBRa6Qk/ejfCdqj0bwQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="iZfbqYJ/"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 793B7606A336; Thu, 22 Oct 2026 20:16:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZfbqYJ/ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792700192; b=c9DHlD1keGVlMkOab9iZoMTwwkYsugdHbOPOPcVMPaQPN/lD4503M0mSnvkMotYSE4jy FXeRSNxkJBZJHofVKIuI5dErUOjGG/eGhyqIDbbgR50rQhOiObaVasCmrj4xYRuYtLX0M qET2jzRSTaif3WyGeiM7rFTneONTB0y1nLNlM25v93OXH9QQI6Ft9airDEFVI8LFugdua wjeca67is1vOeEpx5yKntZwKeRF5s2DH/OecmofDhtG9UNVWk/AoWm1riaqsgOpJpgFDE 0o6P/MVV5QpWb1lbMXQHnmNpI8qicHqnaJ8R2RorU4HN9ZAnEacG+PnHPYYtaBivptw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792700192; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=tnLblktMeZ7lb0jeukkbTTUSpbE1oL5D1vptFoQWo3Q=; b=fCriLG/IwgmYV0G05QSsyuRxX+GIqXI3Vy023Hd/GdE3IwcC0HdFL12/Ny2c2mqqGY/o 2WS893s1LyKPbWmJ8UT/ZUiOIDCbJSZwXcNoCYf1bh3fMonJ53H8wRKvJzzcgRRfTtHUi ixtCQHW6YZneLZjZUZT2V2M7yXH6O0uyLILQkD5u9/JOhFMVNNv9dBGIS0XIOMqXfsxUQ /H7HBPX9sF+2gmtDaUgnVUjZ2eoh5y91Vn12o7TPRBtWEKggClPiKXw5BxpAgQp1Fx8La laOTA4t+Vyn0/3vBBcI0reDv3HFceAq3Sw7ZbzdLGuyXhRaQJNjzCiQeEf+Zfkjx2Vg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="iZfbqYJ/"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51B47606A32C; Thu, 22 Oct 2026 20:16:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 818521F01825; Thu, 22 Oct 2026 20:16:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792700191; bh=tnLblktMeZ7lb0jeukkbTTUSpbE1oL5D1vptFoQWo3Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=iZfbqYJ/Lig7nZSKDfsw6pIyYPOG282sf3ix7naKp2MBtllE50iknZA4bYC65TWiI EuEJxkvIsjMmws8Y/QA4BvX8nEiTaUuyQcdR9JWNIavG4o2GaQ7MffyaEJqg+duKPt c/2Ki0vDPqBuG9OPZB1mW8QGzaBhnM496jVQmSGXN/+9d5MaMeyqkWhiiTDjK9N/C2 d0B/J5ePTQ62SmBfEJhRIAn2rVqgDqcbBX6oU9ornLArw2PhALaSM04FBzia1GsOGh zDLDXhOavqgnPLTjmvo0fYqTGCCOJK7kI8yzjjPiFfhM7PbeTETogk9d4ep+RNgDWo 6cOplA/FCWYNg== X-Cc: netdev@vger.kernel.org, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, andrew+netdev@lunn.ch, linux-usb@vger.kernel.org, kuba@kernel.org X-In-Reply-To: <20261020201537.2465655-1-prashantsengar25031@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list