* [PATCH] net: phy: nxp-tja11xx: cancel registration work on remove
@ 2026-07-28 12:33 Hongyan Xu
2026-07-28 21:11 ` Andrew Lunn
2026-07-29 9:16 ` [PATCH net v2] " Hongyan Xu
0 siblings, 2 replies; 4+ messages in thread
From: Hongyan Xu @ 2026-07-28 12:33 UTC (permalink / raw)
To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
Cc: Hongyan Xu, netdev, linux-kernel, jianhao.xu
tja1102_p0_probe() schedules work to register the second port. The work
uses the Port 0 private data and phydev. The private data is
devm-allocated, but the driver did not cancel the work before detach.
Store the Port 0 private data in phydev->priv and add a remove callback.
The callback waits for the registration work before devres can free it.
This issue was found by a static analysis tool.
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/net/phy/nxp-tja11xx.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index 07e94a247..68062a4c5 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -620,6 +620,7 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return -ENOMEM;
priv->phydev = phydev;
+ phydev->priv = priv;
INIT_WORK(&priv->phy_register_work, tja1102_p1_register);
ret = tja11xx_hwmon_register(phydev, priv);
@@ -631,6 +632,13 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return 0;
}
+static void tja1102_p0_remove(struct phy_device *phydev)
+{
+ struct tja11xx_priv *priv = phydev->priv;
+
+ cancel_work_sync(&priv->phy_register_work);
+}
+
static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)
{
int ret;
@@ -847,6 +855,7 @@ static struct phy_driver tja11xx_driver[] = {
.features = PHY_BASIC_T1_FEATURES,
.flags = PHY_POLL_CABLE_TEST,
.probe = tja1102_p0_probe,
+ .remove = tja1102_p0_remove,
.soft_reset = tja11xx_soft_reset,
.config_aneg = tja11xx_config_aneg,
.config_init = tja11xx_config_init,
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: phy: nxp-tja11xx: cancel registration work on remove
2026-07-28 12:33 [PATCH] net: phy: nxp-tja11xx: cancel registration work on remove Hongyan Xu
@ 2026-07-28 21:11 ` Andrew Lunn
2026-07-29 9:16 ` [PATCH net v2] " Hongyan Xu
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2026-07-28 21:11 UTC (permalink / raw)
To: Hongyan Xu
Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, jianhao.xu
On Tue, Jul 28, 2026 at 08:33:35PM +0800, Hongyan Xu wrote:
> tja1102_p0_probe() schedules work to register the second port. The work
> uses the Port 0 private data and phydev. The private data is
> devm-allocated, but the driver did not cancel the work before detach.
>
> Store the Port 0 private data in phydev->priv and add a remove callback.
> The callback waits for the registration work before devres can free it.
>
> This issue was found by a static analysis tool.
>
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Please take a read of:
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
The Subject: line should indicate which tree this patch should be
applied to.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2] net: phy: nxp-tja11xx: cancel registration work on remove
2026-07-28 12:33 [PATCH] net: phy: nxp-tja11xx: cancel registration work on remove Hongyan Xu
2026-07-28 21:11 ` Andrew Lunn
@ 2026-07-29 9:16 ` Hongyan Xu
2026-07-29 15:08 ` [PATCH net-next v3] " Hongyan Xu
1 sibling, 1 reply; 4+ messages in thread
From: Hongyan Xu @ 2026-07-29 9:16 UTC (permalink / raw)
To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
Cc: Hongyan Xu, netdev, linux-kernel, jianhao.xu
tja1102_p0_probe() schedules work to register the second port. That work
uses the Port 0 private data and phydev. The private data is
devm-allocated, but the driver does not cancel the work before detach.
If the device is removed before the worker runs, devres can free the
private data while the pending work still dereferences it.
Store the Port 0 private data in phydev->priv and add a remove callback.
The callback waits for the registration work before devres can free it.
This issue was found by a static analysis tool.
Fixes: 6a64d3cdc5ef ("net: phy: tja11xx: add delayed registration of TJA1102 PHY1")
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
v2:
- mark the patch for the net tree as suggested by Andrew Lunn
- add the Fixes tag
- no code changes
drivers/net/phy/nxp-tja11xx.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index 07e94a247..68062a4c5 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -620,6 +620,7 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return -ENOMEM;
priv->phydev = phydev;
+ phydev->priv = priv;
INIT_WORK(&priv->phy_register_work, tja1102_p1_register);
ret = tja11xx_hwmon_register(phydev, priv);
@@ -631,6 +632,13 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return 0;
}
+static void tja1102_p0_remove(struct phy_device *phydev)
+{
+ struct tja11xx_priv *priv = phydev->priv;
+
+ cancel_work_sync(&priv->phy_register_work);
+}
+
static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)
{
int ret;
@@ -847,6 +855,7 @@ static struct phy_driver tja11xx_driver[] = {
.features = PHY_BASIC_T1_FEATURES,
.flags = PHY_POLL_CABLE_TEST,
.probe = tja1102_p0_probe,
+ .remove = tja1102_p0_remove,
.soft_reset = tja11xx_soft_reset,
.config_aneg = tja11xx_config_aneg,
.config_init = tja11xx_config_init,
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v3] net: phy: nxp-tja11xx: cancel registration work on remove
2026-07-29 9:16 ` [PATCH net v2] " Hongyan Xu
@ 2026-07-29 15:08 ` Hongyan Xu
0 siblings, 0 replies; 4+ messages in thread
From: Hongyan Xu @ 2026-07-29 15:08 UTC (permalink / raw)
To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
Cc: getshell, netdev, linux-kernel, jianhao.xu
tja1102_p0_probe() schedules work to register the second port. That work
uses the Port 0 private data and phydev. The private data is
devm-allocated, but the driver does not wait for the pending work on
remove.
Store the Port 0 private data in phydev->priv and add a remove callback.
The callback cancels the registration work before devres teardown frees
the state.
This issue was found by a static analysis tool.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
v3:
- drop the Fixes tag
- target net-next instead of net
- no code changes
v2: https://lore.kernel.org/netdev/20260729091621.1726-1-getshell@seu.edu.cn/
v1: https://lore.kernel.org/netdev/20260728123423.781-1-getshell@seu.edu.cn/
drivers/net/phy/nxp-tja11xx.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index 07e94a247..68062a4c5 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -620,6 +620,7 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return -ENOMEM;
priv->phydev = phydev;
+ phydev->priv = priv;
INIT_WORK(&priv->phy_register_work, tja1102_p1_register);
ret = tja11xx_hwmon_register(phydev, priv);
@@ -631,6 +632,13 @@ static int tja1102_p0_probe(struct phy_device *phydev)
return 0;
}
+static void tja1102_p0_remove(struct phy_device *phydev)
+{
+ struct tja11xx_priv *priv = phydev->priv;
+
+ cancel_work_sync(&priv->phy_register_work);
+}
+
static int tja1102_match_phy_device(struct phy_device *phydev, bool port0)
{
int ret;
@@ -847,6 +855,7 @@ static struct phy_driver tja11xx_driver[] = {
.features = PHY_BASIC_T1_FEATURES,
.flags = PHY_POLL_CABLE_TEST,
.probe = tja1102_p0_probe,
+ .remove = tja1102_p0_remove,
.soft_reset = tja11xx_soft_reset,
.config_aneg = tja11xx_config_aneg,
.config_init = tja11xx_config_init,
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-29 15:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 12:33 [PATCH] net: phy: nxp-tja11xx: cancel registration work on remove Hongyan Xu
2026-07-28 21:11 ` Andrew Lunn
2026-07-29 9:16 ` [PATCH net v2] " Hongyan Xu
2026-07-29 15:08 ` [PATCH net-next v3] " Hongyan Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox