Skip to contentSkip to conversation

net: mdio: thunder: Add missing fwnode_handle_put()

PATCH Applied Liang He 3 participants 5 messages Mar 22, 2023 – Mar 23, 2023

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 net: mdio: thunder: Add missing fwnode_handle_put()

In device_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration device_for_each_child_node() as it will automatically increase and decrease the refcounter.

Fixes 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
---
 drivers/net/mdio/mdio-thunder.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mdio/mdio-thunder.c +1 -0
index 822d2cdd2f35..394b864aaa37 100644
@@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
 		if (i >= ARRAY_SIZE(nexus->buses))
 			break;
 	}
+	fwnode_handle_put(fwn);
 	return 0;
 
 err_release_regions:
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Liang He

In device_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration device_for_each_child_node() as it will automatically increase and decrease the refcounter.

Don't forget to mention the tree which you are targeting.
It shoud be something like:
"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and you can achieve this using option --subject-prefix when you create your patch:
git format-patch ... --subject-prefix "PATCH net"

Quoted 12 lines
Fixes 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
---
 drivers/net/mdio/mdio-thunder.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mdio/mdio-thunder.c +0 -0
index 822d2cdd2f35..394b864aaa37 100644

drivers/net/mdio/mdio-thunder.c static int thunder_mdiobus_pci_probe(struct pci_dev *pdev, · line 107

Quoted 4 lines
drivers/net/mdio/mdio-thunder.c +1 -0
@@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
                if (i >= ARRAY_SIZE(nexus->buses))
                        break;
        }
+       fwnode_handle_put(fwn);

Can you declare only 1 mdio bus in the DT under this pci device? Because in that case, I don't think this is correct, because then 'device_for_each_child_node' will exit before all 4 mdio buses are probed. And according to the comments for 'fwnode_handle_put' you need to use with break or return.

Quoted 6 lines
drivers/net/mdio/mdio-thunder.c +0 -1
        return 0;
 
 err_release_regions:
--

2.25.1

Signature · 1 line
/Horatiu
author
#2 lore raw
Quoted 6 lines · Horatiu Vultur
Quoted 4 lines · Liang He

In device_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration device_for_each_child_node() as it will automatically increase and decrease the refcounter.

Quoted 7 lines

Don't forget to mention the tree which you are targeting.
It shoud be something like:
"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and you can achieve this using option --subject-prefix when you create your patch:
git format-patch ... --subject-prefix "PATCH net"

Thanks for your reply and advise, I will add it in my future patches.

Quoted 8 lines
Quoted 8 lines
Fixes 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
---
 drivers/net/mdio/mdio-thunder.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 16 lines

drivers/net/mdio/mdio-thunder.c static int thunder_mdiobus_pci_probe(struct pci_dev *pdev, · line 107

Quoted 9 lines
drivers/net/mdio/mdio-thunder.c +1 -0
index 822d2cdd2f35..394b864aaa37 100644
@@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
                if (i >= ARRAY_SIZE(nexus->buses))
                        break;
        }
+       fwnode_handle_put(fwn);

Can you declare only 1 mdio bus in the DT under this pci device? Because in that case, I don't think this is correct, because then 'device_for_each_child_node' will exit before all 4 mdio buses are probed. And according to the comments for 'fwnode_handle_put' you need to use with break or return.

In fact, the fwnode_handle_put(fwn) consider the NULL-check of fwn, and there are only break, not return, so I think it can work in this case. However, if you prefer to add fwnode_handle_put before break, I can send a new patch.

Thanks,
Liang

Quoted 9 lines
Quoted 6 lines
drivers/net/mdio/mdio-thunder.c +0 -1
        return 0;
 
 err_release_regions:
--

2.25.1

Signature · 1 line
/Horatiu
#3 lore raw
Quoted 43 lines · Liang He
Quoted 6 lines · Horatiu Vultur
Quoted 4 lines · Liang He

In device_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration device_for_each_child_node() as it will automatically increase and decrease the refcounter.

Quoted 7 lines

Don't forget to mention the tree which you are targeting.
It shoud be something like:
"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and you can achieve this using option --subject-prefix when you create your patch:
git format-patch ... --subject-prefix "PATCH net"

Thanks for your reply and advise, I will add it in my future patches.

Quoted 8 lines
Quoted 8 lines
Fixes 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
---
 drivers/net/mdio/mdio-thunder.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 16 lines

drivers/net/mdio/mdio-thunder.c static int thunder_mdiobus_pci_probe(struct pci_dev *pdev, · line 107

Quoted 9 lines
drivers/net/mdio/mdio-thunder.c +1 -0
index 822d2cdd2f35..394b864aaa37 100644
@@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
                if (i >= ARRAY_SIZE(nexus->buses))
                        break;
        }
+       fwnode_handle_put(fwn);

Can you declare only 1 mdio bus in the DT under this pci device? Because in that case, I don't think this is correct, because then 'device_for_each_child_node' will exit before all 4 mdio buses are probed. And according to the comments for 'fwnode_handle_put' you need to use with break or return.

Quoted 4 lines

In fact, the fwnode_handle_put(fwn) consider the NULL-check of fwn, and there are only break, not return, so I think it can work in this case. However, if you prefer to add fwnode_handle_put before break, I can send a new patch.

You are right, fwnode_handle_put checks for NULL.
It is up too you how you prefer.

Quoted 13 lines

Thanks,
Liang

Quoted 9 lines
Quoted 6 lines
drivers/net/mdio/mdio-thunder.c +0 -1
        return 0;
 
 err_release_regions:
--

2.25.1

--
/Horatiu

Signature · 1 line
/Horatiu
#4 lore raw
In reply to Liang He
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Wed, 22 Mar 2023 14:20:57 +0800 you wrote:

In device_for_each_child_node(), we should add fwnode_handle_put() when break out of the iteration device_for_each_child_node() as it will automatically increase and decrease the refcounter.

Fixes 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")

[...]

Here is the summary with links:
- net: mdio: thunder: Add missing fwnode_handle_put()

    https://git.kernel.org/netdev/net/c/b1de5c78ebe9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html