mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Aleksei Sviridkin <f@lex.la>
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>
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	[thread overview]
Message-ID: <2b95dbf5-3ab5-4eaa-88d0-efb93ddb808b@lunn.ch> (raw)
In-Reply-To: <20261009180551.1234107-3-f@lex.la>

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

  parent reply	other threads:[~2026-10-13  2:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 18:05 [PATCH net-next v5 0/4] net: phy: make PHY driver unbind safe against attach and use Aleksei Sviridkin
2026-10-09 18:05 ` [PATCH net-next v5 1/4] net: phy: refuse a second attach before touching the PHY Aleksei Sviridkin
2026-10-09 18:05 ` [PATCH net-next v5 2/4] net: phy: put the driver module the attach took Aleksei Sviridkin
2026-10-10 19:07   ` netdev-bot+sashiko
2026-10-13  2:26   ` Andrew Lunn [this message]
2026-10-13  2:31   ` Andrew Lunn
2026-10-09 18:05 ` [PATCH net-next v5 3/4] net: phy: serialise attach and detach with PHY driver bind and unbind Aleksei Sviridkin
2026-10-10 19:07   ` netdev-bot+sashiko
2026-10-13  2:36   ` Andrew Lunn
2026-10-09 18:05 ` [PATCH net-next v5 4/4] net: phy: make an unbind wait for the attached consumer to detach Aleksei Sviridkin
2026-10-10 19:07   ` netdev-bot+sashiko
2026-10-10 19:44   ` Aleksei Sviridkin
2026-10-13  2:37   ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b95dbf5-3ab5-4eaa-88d0-efb93ddb808b@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=f@lex.la \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®