[PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe

Erick Karanja posted 1 patch 4 months, 1 week ago
drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
Posted by Erick Karanja 4 months, 1 week ago
Add missing of_node_put call to release device node tbi obtained
via for_each_child_of_node.

Fixes: afae5ad78b342 ("net/fsl_pq_mdio: streamline probing of MDIO nodes")

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 577f9b1780ad..de88776dd2a2 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -479,10 +479,12 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
 					"missing 'reg' property in node %pOF\n",
 					tbi);
 				err = -EBUSY;
+				of_node_put(tbi);
 				goto error;
 			}
 			set_tbipa(*prop, pdev,
 				  data->get_tbipa, priv->map, &res);
+			of_node_put(tbi);
 		}
 	}
 
-- 
2.43.0
Re: [PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
Posted by Markus Elfring 4 months, 1 week ago
> Add missing of_node_put call to release device node tbi obtained
> via for_each_child_of_node.

Will it become helpful to append parentheses to function names?

Regards,
Markus
Re: [PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
Posted by Erick Karanja 4 months, 1 week ago
On Fri, 2025-10-03 at 18:32 +0200, Markus Elfring wrote:
> > Add missing of_node_put call to release device node tbi obtained
> > via for_each_child_of_node.
> 
> Will it become helpful to append parentheses to function names?
Yes, it is necessary.
> 
> Regards,
> Markus
Re: [PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
Posted by Simon Horman 4 months, 1 week ago
On Thu, Oct 02, 2025 at 08:46:17PM +0300, Erick Karanja wrote:
> Add missing of_node_put call to release device node tbi obtained
> via for_each_child_of_node.
> 
> Fixes: afae5ad78b342 ("net/fsl_pq_mdio: streamline probing of MDIO nodes")

nit: no blank line here

Slightly more importantly, although the code you are changing
was added by the cited commit, I think that the bug existed before then.
I wonder if the fixes tag should be.

Fixes: daa26ea63c6f ("Merge branch 'octeontx2-fix-bitmap-leaks-in-pf-and-vf'")

> 
> Signed-off-by: Erick Karanja <karanja99erick@gmail.com>

One minor comment on process: as a fix for networking code, most likely this
should be targeted at the net tree. And that should be denoted in the
subject like this:

Subject: [PATCH net] ...

And if you do post an updated version, which is probably not strictly
necessary, please be sure to observe the 24h rule.

See: https://docs.kernel.org/process/maintainer-netdev.html

The code changes themselves look good to me. Thanks.

Reviewed-by: Simon Horman <horms@kernel.org>

...
Re: [PATCH] net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
Posted by Simon Horman 4 months, 1 week ago
On Fri, Oct 03, 2025 at 08:33:24AM +0100, Simon Horman wrote:
> On Thu, Oct 02, 2025 at 08:46:17PM +0300, Erick Karanja wrote:
> > Add missing of_node_put call to release device node tbi obtained
> > via for_each_child_of_node.
> > 
> > Fixes: afae5ad78b342 ("net/fsl_pq_mdio: streamline probing of MDIO nodes")
> 
> nit: no blank line here
> 
> Slightly more importantly, although the code you are changing
> was added by the cited commit, I think that the bug existed before then.
> I wonder if the fixes tag should be.
> 
> Fixes: daa26ea63c6f ("Merge branch 'octeontx2-fix-bitmap-leaks-in-pf-and-vf'")

Sorry the above is obviously bogus.
I should have said:

Fixes: 1577ecef7666 ("netdev: Merge UCC and gianfar MDIO bus drivers")

> 
> > 
> > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> 
> One minor comment on process: as a fix for networking code, most likely this
> should be targeted at the net tree. And that should be denoted in the
> subject like this:
> 
> Subject: [PATCH net] ...
> 
> And if you do post an updated version, which is probably not strictly
> necessary, please be sure to observe the 24h rule.
> 
> See: https://docs.kernel.org/process/maintainer-netdev.html
> 
> The code changes themselves look good to me. Thanks.
> 
> Reviewed-by: Simon Horman <horms@kernel.org>
> 
> ...
>