Article View: linux.kernel.netdev
Article #2586Re: [PATCH net-next v5 2/4] net: phy: put the driver module the attach took
From: Andrew Lunn
Date: Tue, 13 Oct 2026 02:26
Date: Tue, 13 Oct 2026 02:26
38 lines
7545 bytes
7545 bytes
On Fri, Oct 09, 2026 at 09:05:48PM +0300, Aleksei Sviridkin wrote:
> phy_attach_direct() pins the PHY driver module through d->driver, and
> phy_detach() releases it by reading d->driver again. Unbinding the PHY
> driver while the PHY is attached clears that pointer, so a detach that
> runs while the driver is still unbound skips the put and the module can
> no longer be unloaded; if a different driver binds in between, the put
> lands on a module that was never pinned. The NULL test added by
> commit c2b727df7caa ("net: phy: Avoid NPD upon phy_detach() when driver
> is unbound") avoids the oops but skips the put.
>
> Found by reading phy_detach() while chasing a PHY driver unbind race on
> a Keenetic KN-1012 (MT7981, air_en8811h built as a module). The leak
> itself was not observed there: unbinding air_en8811h under the attached
> lan4 DSA port and then unbinding the switch faults earlier on that
> board, in phy_free_interrupt() or under phy_stop(), before
> phy_detach() gets to the put.
>
> Remember which module was pinned and release that one.
>
> Fixes: cafe8df8b9bc ("net: phy: Fix lack of reference count on PHY driver")
> Assisted-by: LLM
> Signed-off-by: Aleksei Sviridkin <f@lex.la>
> ---
> Changes in v5:
> - The driver module is read once, so the module pinned and the module
> recorded cannot differ.
> - Rebased on net-next: the failed generic bind unwind keeps the
> interrupt restore it got there.
Please drop the fixes tag when it is for net-next.
You can then add: Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
---
pw-bot: cr
Technical Details
Message-ID:
<2b95dbf5-3ab5-4eaa-88d0-efb93ddb808b@lunn.ch>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345333-linux-kernel-netdev=dewy.ruReferences:
<20261009180551.1234107-1-f@lex.la> <20261009180551.1234107-3-f@lex.la>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-345333-linux-kernel-netdev=dewy.ru From: andrew@lunn.ch (Andrew Lunn) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 2/4] net: phy: put the driver module the attach took Date: Tue, 13 Oct 2026 04:26:06 +0200 Organization: Usenet Network Message-ID: <2b95dbf5-3ab5-4eaa-88d0-efb93ddb808b@lunn.ch> References: <20261009180551.1234107-1-f@lex.la> <20261009180551.1234107-3-f@lex.la> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1939648"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Jyps34TQZq7/qRiZRkBNV4C+Pgs= sha256:iQXH51yJ4j3vv/3nlGet4EqlGhhCleQixlkisEwf8Qw= sha1:ERhqueUHPYVGA5UvfMJt2cZS9xo= sha256:b8bc4qL66f8fqxwLJcw5US+iYDCdnkXPEaoYrBT8B6o= Content-Disposition: inline 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 B1AB410FD45; Tue, 13 Oct 2026 05:26:35 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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 (1024-bit key) header.d=lunn.ch 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 uCeyhLtEZ5G9; Tue, 13 Oct 2026 05:26:32 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-345333-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 614D310FD41; Tue, 13 Oct 2026 05:26:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id C62312968D; Tue, 13 Oct 2026 02:26:21 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFBB44195A1; Tue, 13 Oct 2026 02:26:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="NodwaO8/" X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 2B3FC2EEE60; Tue, 13 Oct 2026 02:26:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791858379; cv=none; b=Mb+2/B2GpQxWSDCV+8CVKM7PDtRztTqrL5xU1w5KyAQ/8AnVx0IYduMeScZDMJfT9wpbmJ2ciSWEgxDLKAfWX3YDhc7GFmR9vG4EiKmTNIOukyWY8O3jICneRowwYJXFPUec36x3PBS4m3yxafDeHpGMjXWn0uBFVezvophmZ14= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791858379; c=relaxed/simple; bh=3kDh9heXE0eQtgr2hdakiBQbWCgX4gkYwgV8AcwPSgQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AWebEVrEK0+EBGrU5y7SK+E9OBTZj2pEYobzF/OPaZmRFHsz1JmQvDy3Q51tvLNwpsbXzf+kK1oKEc7JJ9QiLVa9dwpreoZTnrhuXbL6H+jYRKxaj0ZYQtEeGg/u7Qh+5M12e3xsSkrjMHTLDqbNyLvbSmf3mjWL92ARCVC5L1E= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=NodwaO8/; arc=none smtp.client-ip=156.67.10.101 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=YTjFqI63+E/Jzn1291GKAg1+nViSz6vqdQACq7dN2MM=; b=NodwaO8/zTBryUuw/vbS1bqQl0 99Y1a9QJ2rtS4WYv5DSuvmlYtahVz4ATsRlhMDQImHmK7/QGeHRvuJiMLh6jQdhVKXYYOqA7JuKvF YHjrsq6Nlmq1jb/gAhK7xLyuqYSDyTRU42ahDWeCj+7SHfl3jlAH4Ge2IQwHWsN/NrZs=; X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from <andrew@lunn.ch>) id 1xGSDO-00AR9o-UL; Tue, 13 Oct 2026 04:26:06 +0200 X-Cc: Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-kernel@vger.kernel.org, Florian Fainelli <f.fainelli@gmail.com>, Woojung Huh <woojung.huh@microchip.com>, Vladimir Oltean <vladimir.oltean@nxp.com>, Maxime Chevallier <maxime.chevallier@bootlin.com> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-In-Reply-To: <20261009180551.1234107-3-f@lex.la>