This series introduces the scoped variant of fwnode_for_each_available_child_node() to avoid the common issue the non-scoped variant triggers: forgetting the required fwnode_handle_put() upon early exits. It is strongly based on the existing device_for_each_child_node_scoped(), using fwnode_get_next_available_child_node() instead, and of course fwnode instead of dev. A fix with this new macro has been proposed in this series, as well as a second fix for a node outside the loop by means of the __free() automatic cleanup mechanism. Given that the bugs were recently introduced, new approaches can be used without affecting stable kernels. Of course the issue could be solved by adding multiple calls to fwnode_handle_put(), but the scoped macros and the automatic cleanup has already showed multiple times that they can save us from introducing bugs and also help us fix existing ones. Note that the declaration of 'leds' has been moved to its initialization as it is preferred when using this mechanism to avoid releasing uninitialized nodes. It could be left on top with a NULL initialization, but that pattern is less common. A more important modification is the use of the _available_ variant of the macro, as it seems that there is no need to walk over unavailable nodes. If that is not the case, please let me know why unavailable nodes are required, as a scoped variant of the current loop could be introduced instead. This series has been compile-checked and statically analyzed, as I don't have the hardware to test it. I have been using the scoped macro for a while downstream, but that is not saying much, and actual tests with the real hardware would be more than welcome. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> --- Javier Carrasco (3): device property: Introduce fwnode_for_each_available_child_node_scoped() net: dsa: mv88e6xxx: leds: fix led refcount in error path net: dsa: mv88e6xxx: leds: fix leds refcount drivers/net/dsa/mv88e6xxx/leds.c | 6 +++--- include/linux/property.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) --- base-commit: 489cee4caeba4f70a29b7215cfd18152dcadab7f change-id: 20241008-mv88e6xxx_leds_fwnode_put-93946e7a87a8 Best regards, -- Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>