]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: mdio: thunder: switch to scoped device_for_each_child_node()
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Mon, 30 Sep 2024 20:38:25 +0000 (22:38 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Oct 2024 16:28:26 +0000 (09:28 -0700)
commit1d39d02a1535658962f9370312be7b2d634946a5
treeee95b6af47451dcd6e10acf9ee4b744975f4e399
parent6443cf1bdf7909f055e2182138ff1f434a741517
net: mdio: thunder: switch to scoped device_for_each_child_node()

There has already been an issue with the handling of early exits from
device_for_each_child() in this driver, and it was solved with commit
b1de5c78ebe9 ("net: mdio: thunder: Add missing fwnode_handle_put()") by
adding a call to fwnode_handle_put() right after the loop.

That solution is valid indeed, but if a new error path with a 'return'
is added to the loop, this solution will fail. A more secure approach
is using the scoped variant of the macro, which automatically
decrements the refcount of the child node when it goes out of scope,
removing the need for explicit calls to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240930-net-device_for_each_child_node_scoped-v2-1-35f09333c1d7@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/mdio/mdio-thunder.c