* [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
@ 2026-11-10 6:41 Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak " Xiangwu Lai
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Xiangwu Lai @ 2026-11-10 6:41 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, danishanwar,
rogerq, jan.kiszka, diogo.ivo, haokexin, horms, linux-arm-kernel,
linux-kernel, Xiangwu Lai
Hello,
This series fixes the device_node handling in prueth_probe() of both
ICSSG drivers.
Patches 1 and 2, carried over from v1 unchanged, fix a device_node
refcount leak on the "ti,mii-g-rt" and "ti,mii-rt" syscon lookup
failure paths. Patches 3 and 4 fix the port scan loop that is shared
by both drivers: a port whose reg property cannot be read is skipped
instead of being routed based on the uninitialized value, the node
reference is taken only for a port that is actually accepted so an
out-of-range reg value no longer leaks it, duplicate reg values are
rejected, which is what the existing "port0 and port1 can't have
same reg" check intended but never caught, and that unreachable
check is dropped.
Thanks to Simon Horman for the review of v1 [1][2] and for suggesting
to collect the fixes into one series.
Changes in v2:
- Collect the two independent fixes into one series (suggested by
Simon Horman).
- Add the port scan fixes for both drivers.
[1] https://lore.kernel.org/netdev/20261109165235.GR18859@horms.kernel.org/
[2] https://lore.kernel.org/netdev/20261109170036.GT18859@horms.kernel.org/
Xiangwu Lai (4):
net: ti: icssg-prueth: Fix device_node refcount leak in prueth_probe()
net: ti: icssg-prueth-sr1: Fix device_node refcount leak in
prueth_probe()
net: ti: icssg-prueth: Fix port scan issues in prueth_probe()
net: ti: icssg-prueth-sr1: Fix port scan issues in prueth_probe()
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 32 +++++++++++--------
.../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 32 +++++++++++--------
2 files changed, 38 insertions(+), 26 deletions(-)
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak in prueth_probe()
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
@ 2026-11-10 6:41 ` Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 2/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Xiangwu Lai @ 2026-11-10 6:41 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, danishanwar,
rogerq, jan.kiszka, diogo.ivo, haokexin, horms, linux-arm-kernel,
linux-kernel, Xiangwu Lai
prueth_probe() takes references on the eth0_node/eth1_node device nodes
with of_node_get() and stores them in prueth->eth_node[]. If either of
the "ti,mii-g-rt" or "ti,mii-rt" syscon regmap lookups fails, probe()
returns -ENODEV without dropping those references, leaking the device
nodes.
Jump to the existing put_cores label so the error path releases the
eth0_node/eth1_node references like all the other failure paths in the
function do.
Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
Changes in v2:
- Collect the two independent fixes into one series (suggested by
Simon Horman).
- No code change since v1.
Link: https://lore.kernel.org/netdev/20261030085651.1944-1-laixiangwu@cmss.chinamobile.com/
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 591be5c80..9b971d1df 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -2258,13 +2258,15 @@ static int prueth_probe(struct platform_device *pdev)
prueth->miig_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-g-rt");
if (IS_ERR(prueth->miig_rt)) {
dev_err(dev, "couldn't get ti,mii-g-rt syscon regmap\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_cores;
}
prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt");
if (IS_ERR(prueth->mii_rt)) {
dev_err(dev, "couldn't get ti,mii-rt syscon regmap\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_cores;
}
prueth->pa_stats = syscon_regmap_lookup_by_phandle(np, "ti,pa-stats");
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 net 2/4] net: ti: icssg-prueth-sr1: Fix device_node refcount leak in prueth_probe()
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak " Xiangwu Lai
@ 2026-11-10 6:41 ` Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 3/4] net: ti: icssg-prueth: Fix port scan issues " Xiangwu Lai
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Xiangwu Lai @ 2026-11-10 6:41 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, danishanwar,
rogerq, jan.kiszka, diogo.ivo, haokexin, horms, linux-arm-kernel,
linux-kernel, Xiangwu Lai
prueth_probe() takes references on the eth0_node/eth1_node device nodes
with of_node_get() and stores them in prueth->eth_node[]. If either of
the "ti,mii-g-rt" or "ti,mii-rt" syscon regmap lookups fails, probe()
returns -ENODEV without dropping those references, leaking the device
nodes.
Jump to the existing put_cores label so the error path releases the
eth0_node/eth1_node references like all the other failure paths in the
function do.
Fixes: e654b85a693e ("net: ti: icssg-prueth: Add ICSSG Ethernet driver for AM65x SR1.0 platforms")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
Changes in v2:
- Collect the two independent fixes into one series (suggested by
Simon Horman).
- No code change since v1.
Link: https://lore.kernel.org/netdev/20261030085851.2019-1-laixiangwu@cmss.chinamobile.com/
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index b8115ca47..ef1dc32ff 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -963,13 +963,15 @@ static int prueth_probe(struct platform_device *pdev)
prueth->miig_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-g-rt");
if (IS_ERR(prueth->miig_rt)) {
dev_err(dev, "couldn't get ti,mii-g-rt syscon regmap\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_cores;
}
prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt");
if (IS_ERR(prueth->mii_rt)) {
dev_err(dev, "couldn't get ti,mii-rt syscon regmap\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_cores;
}
if (eth0_node) {
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 net 3/4] net: ti: icssg-prueth: Fix port scan issues in prueth_probe()
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak " Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 2/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
@ 2026-11-10 6:41 ` Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 4/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
2026-11-10 6:46 ` [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling " netdev-bot+sinfo
4 siblings, 0 replies; 6+ messages in thread
From: Xiangwu Lai @ 2026-11-10 6:41 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, danishanwar,
rogerq, jan.kiszka, diogo.ivo, haokexin, horms, linux-arm-kernel,
linux-kernel, Xiangwu Lai
The port scan loop in prueth_probe() has several issues:
- When reading the reg property of a port fails, the error is only
logged and the uninitialized value of reg is then used to decide
which slot the port node is stored in.
- of_node_get() is called on every port child before the reg value is
validated. If reg is neither 0 nor 1, the reference is never
released. If two ports use the same reg value, the second
assignment overwrites the first pointer and its reference is lost.
- The "port0 and port1 can't have same reg" check after the loop is
dead code: both variables are initialized to NULL, each iteration
assigns at most one of them, for_each_child_of_node() visits each
child exactly once, and the both-NULL case is handled by the
preceding check.
Fix the first issue by skipping a port when its reg property cannot
be read, and the second by taking the reference only when a port is
actually accepted. Reject duplicate reg values, which is what the
existing check intended but never caught, and remove the unreachable
check.
Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 26 +++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 9b971d1df..c19a51174 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -2217,24 +2217,34 @@ static int prueth_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(dev, "%pOF error reading port_id %d\n",
eth_node, ret);
+ continue;
}
- of_node_get(eth_node);
+ if (reg != 0 && reg != 1) {
+ dev_err(dev, "port reg should be 0 or 1\n");
+ continue;
+ }
+
+ if ((reg == 0 && eth0_node) || (reg == 1 && eth1_node)) {
+ dev_err(dev, "port reg %d already in use\n", reg);
+ ret = -ENODEV;
+ of_node_put(eth_node);
+ of_node_put(eth_ports_node);
+ goto put_cores;
+ }
if (reg == 0) {
- eth0_node = eth_node;
+ eth0_node = of_node_get(eth_node);
if (!of_device_is_available(eth0_node)) {
of_node_put(eth0_node);
eth0_node = NULL;
}
} else if (reg == 1) {
- eth1_node = eth_node;
+ eth1_node = of_node_get(eth_node);
if (!of_device_is_available(eth1_node)) {
of_node_put(eth1_node);
eth1_node = NULL;
}
- } else {
- dev_err(dev, "port reg should be 0 or 1\n");
}
}
@@ -2246,12 +2256,6 @@ static int prueth_probe(struct platform_device *pdev)
return -ENODEV;
}
- if (eth0_node == eth1_node) {
- dev_err(dev, "port0 and port1 can't have same reg\n");
- of_node_put(eth0_node);
- return -ENODEV;
- }
-
prueth->eth_node[PRUETH_MAC0] = eth0_node;
prueth->eth_node[PRUETH_MAC1] = eth1_node;
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 net 4/4] net: ti: icssg-prueth-sr1: Fix port scan issues in prueth_probe()
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
` (2 preceding siblings ...)
2026-11-10 6:41 ` [PATCH v2 net 3/4] net: ti: icssg-prueth: Fix port scan issues " Xiangwu Lai
@ 2026-11-10 6:41 ` Xiangwu Lai
2026-11-10 6:46 ` [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling " netdev-bot+sinfo
4 siblings, 0 replies; 6+ messages in thread
From: Xiangwu Lai @ 2026-11-10 6:41 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, danishanwar,
rogerq, jan.kiszka, diogo.ivo, haokexin, horms, linux-arm-kernel,
linux-kernel, Xiangwu Lai
The port scan loop in prueth_probe() has several issues:
- When reading the reg property of a port fails, the error is only
logged and the uninitialized value of reg is then used to decide
which slot the port node is stored in.
- of_node_get() is called on every port child before the reg value is
validated. If reg is neither 0 nor 1, the reference is never
released. If two ports use the same reg value, the second
assignment overwrites the first pointer and its reference is lost.
- The "port0 and port1 can't have same reg" check after the loop is
dead code: both variables are initialized to NULL, each iteration
assigns at most one of them, for_each_child_of_node() visits each
child exactly once, and the both-NULL case is handled by the
preceding check.
Fix the first issue by skipping a port when its reg property cannot
be read, and the second by taking the reference only when a port is
actually accepted. Reject duplicate reg values, which is what the
existing check intended but never caught, and remove the unreachable
check.
Fixes: e654b85a693e ("net: ti: icssg-prueth: Add ICSSG Ethernet driver for AM65x SR1.0 platforms")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
.../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 26 +++++++++++--------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index ef1dc32ff..1a9dd70b2 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -922,24 +922,34 @@ static int prueth_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(dev, "%pOF error reading port_id %d\n",
eth_node, ret);
+ continue;
}
- of_node_get(eth_node);
+ if (reg != 0 && reg != 1) {
+ dev_err(dev, "port reg should be 0 or 1\n");
+ continue;
+ }
+
+ if ((reg == 0 && eth0_node) || (reg == 1 && eth1_node)) {
+ dev_err(dev, "port reg %d already in use\n", reg);
+ ret = -ENODEV;
+ of_node_put(eth_node);
+ of_node_put(eth_ports_node);
+ goto put_cores;
+ }
if (reg == 0) {
- eth0_node = eth_node;
+ eth0_node = of_node_get(eth_node);
if (!of_device_is_available(eth0_node)) {
of_node_put(eth0_node);
eth0_node = NULL;
}
} else if (reg == 1) {
- eth1_node = eth_node;
+ eth1_node = of_node_get(eth_node);
if (!of_device_is_available(eth1_node)) {
of_node_put(eth1_node);
eth1_node = NULL;
}
- } else {
- dev_err(dev, "port reg should be 0 or 1\n");
}
}
@@ -951,12 +961,6 @@ static int prueth_probe(struct platform_device *pdev)
return -ENODEV;
}
- if (eth0_node == eth1_node) {
- dev_err(dev, "port0 and port1 can't have same reg\n");
- of_node_put(eth0_node);
- return -ENODEV;
- }
-
prueth->eth_node[PRUETH_MAC0] = eth0_node;
prueth->eth_node[PRUETH_MAC1] = eth1_node;
--
2.50.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
` (3 preceding siblings ...)
2026-11-10 6:41 ` [PATCH v2 net 4/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
@ 2026-11-10 6:46 ` netdev-bot+sinfo
4 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sinfo @ 2026-11-10 6:46 UTC (permalink / raw)
To: Xiangwu Lai
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni,
danishanwar, rogerq, jan.kiszka, diogo.ivo, haokexin, horms,
linux-arm-kernel, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by code inspection). If it was triggered please include
the symptoms, like the stack trace or error messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-10 6:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 6:41 [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe() Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak " Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 2/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 3/4] net: ti: icssg-prueth: Fix port scan issues " Xiangwu Lai
2026-11-10 6:41 ` [PATCH v2 net 4/4] net: ti: icssg-prueth-sr1: " Xiangwu Lai
2026-11-10 6:46 ` [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling " netdev-bot+sinfo
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®