From: Jiale Yao <yaojiale02@163.com>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Christophe Leroy <chleroy@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] net: phy: only remove owned topology entries
Date: Wed, 28 Oct 2026 13:03:12 +0800 [thread overview]
Message-ID: <20261028050312.126508-1-yaojiale02@163.com> (raw)
phy_link_topo_add_phy() can fail to insert a PHY when its saved index is
already occupied. Its caller may subsequently run the normal detach
path. phy_link_topo_del_phy() then unconditionally removes the entry at
that index, including its ports, even though the entry belongs to a
different PHY.
Look up the topology entry first and only remove the PHY and its ports
when the entry belongs to the PHY being detached.
Fixes: 384968786909 ("net: phy: Introduce ethernet link topology representation")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/net/phy/phy_link_topology.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/phy/phy_link_topology.c b/drivers/net/phy/phy_link_topology.c
index 214ccce23cf6..175eef44cf54 100644
--- a/drivers/net/phy/phy_link_topology.c
+++ b/drivers/net/phy/phy_link_topology.c
@@ -185,6 +185,10 @@ void phy_link_topo_del_phy(struct net_device *dev,
if (!topo)
return;
+ pdn = xa_load(&topo->phys, phy->phyindex);
+ if (!pdn || pdn->phy != phy)
+ return;
+
list_for_each_entry(port, &phy->ports, head)
phy_link_topo_del_port(dev, port);
--
2.34.1
next reply other threads:[~2026-10-28 5:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 5:03 Jiale Yao [this message]
2026-10-28 5:06 ` netdev-bot+sinfo
2026-10-28 7:10 ` Maxime Chevallier
2026-10-28 12:55 ` 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=20261028050312.126508-1-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=andrew@lunn.ch \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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=stable@vger.kernel.org \
/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®