Thread View: linux.kernel.netdev
11 messages
11 total messages
Started by Xiangwu Lai
Tue, 10 Nov 2026 06:41
[PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 06:41
Date: Tue, 10 Nov 2026 06:41
43 lines
10290 bytes
10290 bytes
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
[PATCH v2 net 1/4] net: ti: icssg-prueth: Fix device_node refcount leak in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 06:41
Date: Tue, 10 Nov 2026 06:41
50 lines
10557 bytes
10557 bytes
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
[PATCH v2 net 2/4] net: ti: icssg-prueth-sr1: Fix device_node refcount leak in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 06:41
Date: Tue, 10 Nov 2026 06:41
50 lines
10614 bytes
10614 bytes
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
[PATCH v2 net 3/4] net: ti: icssg-prueth: Fix port scan issues in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 06:41
Date: Tue, 10 Nov 2026 06:41
89 lines
11753 bytes
11753 bytes
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
[PATCH v2 net 4/4] net: ti: icssg-prueth-sr1: Fix port scan issues in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 06:41
Date: Tue, 10 Nov 2026 06:41
89 lines
11831 bytes
11831 bytes
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
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: netdev-bot+sinfo
Date: Tue, 10 Nov 2026 06:46
Date: Tue, 10 Nov 2026 06:46
26 lines
8969 bytes
8969 bytes
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.
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: Xiangwu Lai
Date: Tue, 10 Nov 2026 07:31
Date: Tue, 10 Nov 2026 07:31
43 lines
10864 bytes
10864 bytes
Hi, Please find below the additional information requested for this series. The same information was provided for the v1 postings of patches 1 and 2 here: https://lore.kernel.org/netdev/20261109093000.54321-laixiangwu@cmss.chinamobile.com/ https://lore.kernel.org/netdev/20261109093500.54322-laixiangwu@cmss.chinamobile.com/ How the issues were discovered: manual code inspection of the error paths in prueth_probe() while auditing both ICSSG drivers for probe-time resource leaks. The port scan issues addressed by patches 3 and 4 were found in the same audit; the use of the uninitialized reg value was also raised during the review of v1. Whether the issues were actually triggered: no, they are purely theoretical, all of them require a malformed device tree: - Patches 1 and 2: the leak triggers only when the "ti,mii-g-rt" or "ti,mii-rt" syscon regmap lookup fails, which does not happen on a valid DT. probe() then fails with -ENODEV and the references taken on eth0_node/eth1_node are leaked silently; there is no stack trace or error message pointing at the leak itself. - Patches 3 and 4: the uninitialized reg value is only used when a port node has no reg property, and a reference is only leaked for port nodes with a reg value outside 0/1 or with a duplicate reg value. On a valid DT (one port with reg 0 and one with reg 1) the loop behaves as before, with identical reference accounting for the accepted ports. Hardware the change was tested on: none, the series was not tested on real hardware. Patches 1 and 2 only re-route two error branches to the existing put_cores label, which is already exercised by the other failure paths in the same function (e.g. prueth_get_cores() failures). Patches 3 and 4 move of_node_get() from an unconditional call on every port child to the assignment points, so for ports that are accepted the reference accounting is unchanged, and the new error path only releases references it has just taken. Best regards, Xiangwu Lai
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: Xiangwu Lai
Date: Wed, 11 Nov 2026 10:32
Date: Wed, 11 Nov 2026 10:32
18 lines
9402 bytes
9402 bytes
Hi, The netdev patchwork cc_maintainers check reports that some people listed by get_maintainer.pl for the files touched by this series were not on Cc: - Vignesh Raghavendra <vigneshr@ti.com> (original contributor of the ICSSG driver code this series fixes) - Meghana Malladi <m-malladi@ti.com> - Jacob Keller <jacob.e.keller@intel.com> Adding them here for visibility. They will be included directly in the Cc list of any future revision of the series. No action is required from them. Best regards, Xiangwu Lai
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: Jakub Kicinski
Date: Thu, 12 Nov 2026 17:37
Date: Thu, 12 Nov 2026 17:37
7 lines
8070 bytes
8070 bytes
On Tue, 10 Nov 2026 15:31:38 +0800 Xiangwu Lai wrote: > The same information was provided for the v1 postings of > patches 1 and 2 here: If only you read the message the bot sent you would would know that you're supposed to add this to the cover letter when respinning.
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: patchwork-bot+netdevbpf
Date: Thu, 12 Nov 2026 17:40
Date: Thu, 12 Nov 2026 17:40
39 lines
9664 bytes
9664 bytes
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 10 Nov 2026 14:41:13 +0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v2,net,1/4] net: ti: icssg-prueth: Fix device_node refcount leak in prueth_probe()
https://git.kernel.org/netdev/net-next/c/562687bb3da5
- [v2,net,2/4] net: ti: icssg-prueth-sr1: Fix device_node refcount leak in prueth_probe()
https://git.kernel.org/netdev/net-next/c/17d181b3789d
- [v2,net,3/4] net: ti: icssg-prueth: Fix port scan issues in prueth_probe()
https://git.kernel.org/netdev/net-next/c/677ad7add2fe
- [v2,net,4/4] net: ti: icssg-prueth-sr1: Fix port scan issues in prueth_probe()
https://git.kernel.org/netdev/net-next/c/e74ec6f501bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH v2 net 0/4] net: ti: icssg: Fix device_node handling in prueth_probe()
Author: Xiangwu Lai
Date: Fri, 13 Nov 2026 10:36
Date: Fri, 13 Nov 2026 10:36
23 lines
9803 bytes
9803 bytes
On Thu, 12 Nov 2026 09:37:06 -0800, Jakub Kicinski wrote: > If only you read the message the bot sent you would would know that > you're supposed to add this to the cover letter when respinning. You are right, my apologies. The bot's message clearly says that if the series needs another revision, the information should be included in the commit messages then. Since I was respinning this series anyway, that was the time to fold it into the cover letter and the commit messages, instead of replying with links to the v1 threads and leaving reviewers to chase the information across postings. Thank you for applying the series, and for the fixups in the applied commits. The added note "untested fix to unlikely driver error path" matches reality: the series was not tested on real hardware, and the affected error paths are only reachable with a malformed device tree. Thanks also for correcting the Signed-off-by name. I will include this information in the commit messages directly in future fix series. Best regards, Xiangwu Lai
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads