netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net, device property: fix led node releases in mv88e6xxx with new macro
@ 2024-10-08 16:10 Javier Carrasco
  2024-10-08 16:10 ` [PATCH net-next 1/3] device property: Introduce fwnode_for_each_available_child_node_scoped() Javier Carrasco
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Javier Carrasco @ 2024-10-08 16:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Andy Shevchenko,
	Daniel Scally, Heikki Krogerus, Sakari Ailus, Andrew Lunn,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Linus Walleij
  Cc: linux-acpi, linux-kernel, netdev, Javier Carrasco

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@gmail.com>
---
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@gmail.com>


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-10-11 12:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 16:10 [PATCH net-next 0/3] net, device property: fix led node releases in mv88e6xxx with new macro Javier Carrasco
2024-10-08 16:10 ` [PATCH net-next 1/3] device property: Introduce fwnode_for_each_available_child_node_scoped() Javier Carrasco
2024-10-10 14:32   ` Andy Shevchenko
2024-10-11  5:39   ` Sakari Ailus
2024-10-11  8:34     ` Javier Carrasco
2024-10-11  9:54       ` Sakari Ailus
2024-10-11 12:04         ` Javier Carrasco
2024-10-08 16:10 ` [PATCH net-next 2/3] net: dsa: mv88e6xxx: leds: fix led refcount in error path Javier Carrasco
2024-10-08 16:38   ` Andrew Lunn
2024-10-10 14:30   ` Andy Shevchenko
2024-10-08 16:10 ` [PATCH net-next 3/3] net: dsa: mv88e6xxx: leds: fix leds refcount Javier Carrasco
2024-10-08 16:40   ` Andrew Lunn
2024-10-08 23:31     ` Javier Carrasco
2024-10-10 14:33   ` Andy Shevchenko
2024-10-10 19:15     ` Javier Carrasco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).