mbox series

[0/2] leds: max5970: fix unreleased fwnode_handle in probe function

Message ID 20241019-max5970-of_node_put-v1-0-e6ce4af4119b@gmail.com
Headers show
Series leds: max5970: fix unreleased fwnode_handle in probe function | expand

Message

Javier Carrasco Oct. 19, 2024, 7:36 p.m. UTC
This series fixes the wrong management of the 'led_node' fwnode_handle,
which is not released after it is no longer required. This affects both
the normal path of execution and the existing error paths (currently
two) in max5970_led_probe().

First, the missing callst to fwnode_handle_put() in the different code
paths are added, to make the patch available for stable kernels. Then,
the code gets updated to a more robust approach by means of the __free()
macro to automatically release the 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>
---
Javier Carrasco (2):
      leds: max5970: fix unreleased fwnode_handle in probe function
      leds: max5970: use cleanup facility for fwnode_handle led_node

 drivers/leds/leds-max5970.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
base-commit: f2493655d2d3d5c6958ed996b043c821c23ae8d3
change-id: 20241019-max5970-of_node_put-939b004f57d2

Best regards,

Comments

Lee Jones Oct. 31, 2024, 4:12 p.m. UTC | #1
On Sat, 19 Oct 2024 21:36:43 +0200, Javier Carrasco wrote:
> An object initialized via device_get_named_child_node() requires calls
> to fwnode_handle_put() when it is no longer required to avoid leaking
> memory.
> 
> Add the missing calls to fwnode_handle_put() in the different paths
> (error paths and normal exit).
> 
> [...]

Applied, thanks!

[1/2] leds: max5970: fix unreleased fwnode_handle in probe function
      commit: 42c04062ba3cd1f2aef96dc160e0ab4b45b5e10a

--
Lee Jones [李琼斯]
Lee Jones Oct. 31, 2024, 4:14 p.m. UTC | #2
On Thu, 31 Oct 2024, Lee Jones wrote:

> On Sat, 19 Oct 2024 21:36:43 +0200, Javier Carrasco wrote:
> > An object initialized via device_get_named_child_node() requires calls
> > to fwnode_handle_put() when it is no longer required to avoid leaking
> > memory.
> > 
> > Add the missing calls to fwnode_handle_put() in the different paths
> > (error paths and normal exit).
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/2] leds: max5970: fix unreleased fwnode_handle in probe function
>       commit: 42c04062ba3cd1f2aef96dc160e0ab4b45b5e10a

Unapplied.