net: Fix 2 OF device node refcount leakage issues
cover net: Fix 2 OF device node refcount leakage issues
This patch series is to fix 2 OF device node refcount leakage issues.
---
Zijun Hu (2):
net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels()
net: bcmasp: Fix device node refcount leakage in bcmasp_probe()
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 1 + drivers/net/pse-pd/tps23881.c | 1 + 2 files changed, 2 insertions(+)
---
base-commit: ff7afaeca1a15fbeaa2c4795ee806c0667bd77b2
change-id: 20241206-drivers_fix-735f56ed5ec7
Best regards,
Signature · 1 line
Zijun Hu <[email protected]>
PATCH 1/2 net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels()
From: Zijun Hu <[email protected]>
tps23881_get_of_channels() invokes of_find_node_by_name(@priv->np, ...) and the callee will put OF device node @priv->np refcount, but the caller does not compensate the refcount before the invocation, so causes the node refcount leakage.
Fix by of_node_get(@priv->np) before the invocation.
--- drivers/net/pse-pd/tps23881.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/pse-pd/tps23881.c +1 -0
@@ -216,6 +216,7 @@ tps23881_get_of_channels(struct tps23881_priv *priv,if (!priv->np)return -EINVAL ; +of_node_get (priv->np); channels_node =of_find_node_by_name (priv->np,"channels" );if (!channels_node)return -EINVAL ;
Signature · 1 line
2.34.1
PATCH 2/2 net: bcmasp: Fix device node refcount leakage in bcmasp_probe()
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
bcmasp_probe() invokes of_find_node_by_name(@dev->of_node, ...) and the callee will put OF device node @dev->of_node refcount, but the caller does not compensate the refcount before the invocation, so causes the node refcount leakage.
Fix by of_node_get(@dev->of_node) before the invocation.
--- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +1 -0
@@ -1367,6 +1367,7 @@ static int bcmasp_probe(struct platform_device *pdev)bcmasp_core_init (priv);bcmasp_core_init_filters (priv); +of_node_get (dev->of_node); ports_node =of_find_node_by_name (dev->of_node,"ethernet-ports" );if (!ports_node) {dev_warn (dev,"No ports found\n" );
Signature · 1 line
2.34.1
Kory Maincent
maintainerQuoted 8 lines · On Thu, 12 Dec 2024 23:06:53 +0800 Zijun Hu <[email protected]> wrote:
This patch series is to fix 2 OF device node refcount leakage issues.
Signed-off-by Zijun Hu <[email protected]>---
Zijun Hu (2):
net: pse-pd: tps23881: Fix device node refcount leakage intps23881_get_of_channels()net: bcmasp: Fix device node refcount leakage inbcmasp_probe()
Thanks for the patch. This fix was already sent by Zhang Zekun:
https://lore.kernel.org/netdev/[email protected]/
net maintainers would prefer to have the API changed as calling of_node_get before of_find_node_by_name is not intuitive.
Still, don't know if we should fix it until the API is changed?
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 12 lines · Kory Maincent
Quoted 8 lines · On Thu, 12 Dec 2024 23:06:53 +0800 Zijun Hu <[email protected]> wrote:
This patch series is to fix 2 OF device node refcount leakage issues.
Signed-off-by Zijun Hu <[email protected]>---
Zijun Hu (2):
net: pse-pd: tps23881: Fix device node refcount leakage intps23881_get_of_channels()net: bcmasp: Fix device node refcount leakage inbcmasp_probe()
Quoted 3 lines
Thanks for the patch. This fix was already sent by Zhang Zekun:
https://lore.kernel.org/netdev/[email protected]/
thank you for sharing this info.
Quoted 3 lines
net maintainers would prefer to have the API changed as calling
of_node_getbeforeof_find_node_by_nameis not intuitive.
agree.
Quoted 2 lines
Still, don't know if we should fix it until the API is changed?
(^^)
Quoted 1 line
Regards,