* [PATCH net 1/2] net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels()
2024-12-12 15:06 [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Zijun Hu
@ 2024-12-12 15:06 ` Zijun Hu
2024-12-12 15:06 ` [PATCH net 2/2] net: bcmasp: Fix device node refcount leakage in bcmasp_probe() Zijun Hu
2024-12-12 15:33 ` [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Kory Maincent
2 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2024-12-12 15:06 UTC (permalink / raw)
To: Oleksij Rempel, Kory Maincent, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Justin Chen,
Florian Fainelli, Simon Horman
Cc: Zijun Hu, netdev, linux-kernel, bcm-kernel-feedback-list, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
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.
Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/net/pse-pd/tps23881.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
index 5c4e88be46ee3316330e26a68d06540ff1db86ff..f5c04dd5be379f7b9697e067a32d59028f446088 100644
--- a/drivers/net/pse-pd/tps23881.c
+++ b/drivers/net/pse-pd/tps23881.c
@@ -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;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net 2/2] net: bcmasp: Fix device node refcount leakage in bcmasp_probe()
2024-12-12 15:06 [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Zijun Hu
2024-12-12 15:06 ` [PATCH net 1/2] net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels() Zijun Hu
@ 2024-12-12 15:06 ` Zijun Hu
2024-12-12 15:33 ` [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Kory Maincent
2 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2024-12-12 15:06 UTC (permalink / raw)
To: Oleksij Rempel, Kory Maincent, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Justin Chen,
Florian Fainelli, Simon Horman
Cc: Zijun Hu, netdev, linux-kernel, bcm-kernel-feedback-list, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
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.
Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index 297c2682a9cf979fbc4af211139f1b1ed0df01d5..517593c5894568111111aff0f6919fb02d780c85 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -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");
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues
2024-12-12 15:06 [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Zijun Hu
2024-12-12 15:06 ` [PATCH net 1/2] net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels() Zijun Hu
2024-12-12 15:06 ` [PATCH net 2/2] net: bcmasp: Fix device node refcount leakage in bcmasp_probe() Zijun Hu
@ 2024-12-12 15:33 ` Kory Maincent
2024-12-13 10:50 ` Zijun Hu
2 siblings, 1 reply; 5+ messages in thread
From: Kory Maincent @ 2024-12-12 15:33 UTC (permalink / raw)
To: Zijun Hu
Cc: Oleksij Rempel, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Justin Chen, Florian Fainelli,
Simon Horman, netdev, linux-kernel, bcm-kernel-feedback-list,
Zijun Hu
On Thu, 12 Dec 2024 23:06:53 +0800
Zijun Hu <zijun_hu@icloud.com> wrote:
> This patch series is to fix 2 OF device node refcount leakage issues.
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> 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()
Thanks for the patch. This fix was already sent by Zhang Zekun:
https://lore.kernel.org/netdev/20241024015909.58654-1-zhangzekun11@huawei.com/
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,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues
2024-12-12 15:33 ` [PATCH net 0/2] net: Fix 2 OF device node refcount leakage issues Kory Maincent
@ 2024-12-13 10:50 ` Zijun Hu
0 siblings, 0 replies; 5+ messages in thread
From: Zijun Hu @ 2024-12-13 10:50 UTC (permalink / raw)
To: Kory Maincent
Cc: Oleksij Rempel, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Justin Chen, Florian Fainelli,
Simon Horman, netdev, linux-kernel, bcm-kernel-feedback-list,
Zijun Hu
On 2024/12/12 23:33, Kory Maincent wrote:
> On Thu, 12 Dec 2024 23:06:53 +0800
> Zijun Hu <zijun_hu@icloud.com> wrote:
>
>> This patch series is to fix 2 OF device node refcount leakage issues.
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>> ---
>> 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()
>
> Thanks for the patch. This fix was already sent by Zhang Zekun:
> https://lore.kernel.org/netdev/20241024015909.58654-1-zhangzekun11@huawei.com/
>
thank you for sharing this info.
> net maintainers would prefer to have the API changed as calling of_node_get
> before of_find_node_by_name is not intuitive.
>
agree.
> Still, don't know if we should fix it until the API is changed?
>
(^^)
> Regards,
^ permalink raw reply [flat|nested] 5+ messages in thread