From: Andrew Lunn <andrew@lunn.ch>
To: Xuanqiang Luo <xuanqiang.luo@linux.dev>
Cc: netdev@vger.kernel.org, kuba@kernel.org,
maxime.chevallier@bootlin.com, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, chleroy@kernel.org,
linux-kernel@vger.kernel.org,
Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: Re: [PATCH net v3 2/5] net: phy: unregister SFP upstream before port cleanup
Date: Wed, 19 Aug 2026 15:36:52 +0200 [thread overview]
Message-ID: <75de5cd8-662e-4874-86dc-5f9c5cd6ca5b@lunn.ch> (raw)
In-Reply-To: <20260819060236.24665-3-xuanqiang.luo@linux.dev>
On Wed, Aug 19, 2026 at 02:02:33PM +0800, Xuanqiang Luo wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>
> Commit 4497f5028675 ("net: phy: Clean the phy_ports after unregistering
> the downstream SFP bus") established that an SFP upstream must be
> unregistered before its phy_ports are destroyed because SFP callbacks
> may access these ports.
>
> phy_setup_ports() does not follow this order when a later port setup
> step fails after phy_sfp_probe() succeeds. It destroys the SFP phy_port
> and leaves phy_probe() to unregister the upstream later, creating a race
> between port destruction and SFP upstream callbacks.
>
> The error unwind is also split across three functions. If
> phy_setup_sfp_port() fails, phy_sfp_probe() leaves the upstream
> registered and relies on phy_probe() to remove it after
> phy_setup_ports() returns.
>
> Make each layer unwind the resources it successfully set up. Unregister
> only the upstream in phy_sfp_probe() when SFP port setup fails, since
> the failed port has already been destroyed. Add phy_sfp_release() for a
> successful SFP probe, and make phy_setup_ports() use it before cleaning
> up the remaining ports. Once phy_setup_ports() has rolled back all port
> setup, make phy_probe() skip this cleanup.
>
> Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation")
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
next prev parent reply other threads:[~2026-08-19 13:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 6:02 [PATCH net v3 0/5] net: phy: fix cleanup after probe failure Xuanqiang Luo
2026-08-19 6:02 ` [PATCH net v3 1/5] net: phy: split phy_probe() error paths Xuanqiang Luo
2026-08-19 13:35 ` Andrew Lunn
2026-08-20 10:05 ` Xuanqiang Luo
2026-08-19 6:02 ` [PATCH net v3 2/5] net: phy: unregister SFP upstream before port cleanup Xuanqiang Luo
2026-08-19 13:36 ` Andrew Lunn [this message]
2026-08-19 6:02 ` [PATCH net v3 3/5] net: phy: set PHY_READY after LED setup Xuanqiang Luo
2026-08-19 13:37 ` Andrew Lunn
2026-08-20 10:06 ` Xuanqiang Luo
2026-08-20 14:26 ` Andrew Lunn
2026-08-19 6:02 ` [PATCH net v3 4/5] net: phy: call driver remove when core initialization fails Xuanqiang Luo
2026-08-19 13:37 ` Andrew Lunn
2026-08-19 6:02 ` [PATCH net v3 5/5] net: phy: propagate errors from default port setup Xuanqiang Luo
2026-08-19 9:27 ` Maxime Chevallier
2026-08-19 13:33 ` [PATCH net v3 0/5] net: phy: fix cleanup after probe failure Andrew Lunn
2026-08-20 17:46 ` Jakub Kicinski
2026-08-20 18:22 ` Andrew Lunn
2026-08-21 6:44 ` Xuanqiang Luo
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=75de5cd8-662e-4874-86dc-5f9c5cd6ca5b@lunn.ch \
--to=andrew@lunn.ch \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luoxuanqiang@kylinos.cn \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xuanqiang.luo@linux.dev \
/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®