Skip to content

Commit 02f58f9

Browse files
javiercarrascocruzlag-linaro
authored andcommitted
leds: max5970: Fix unreleased fwnode_handle in probe function
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 automatic cleanup facility for 'led_node' to ensure that fwnode_handle_put() is called in all execution paths. Fixes: 736214b ("leds: max5970: Add support for max5970") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20241031-max5970-of_node_put-v2-1-0ffe1f1d3bc9@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 32360bf commit 02f58f9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/leds/leds-max5970.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int max5970_led_set_brightness(struct led_classdev *cdev,
4545

4646
static int max5970_led_probe(struct platform_device *pdev)
4747
{
48-
struct fwnode_handle *led_node, *child;
48+
struct fwnode_handle *child;
4949
struct device *dev = &pdev->dev;
5050
struct regmap *regmap;
5151
struct max5970_led *ddata;
@@ -55,7 +55,8 @@ static int max5970_led_probe(struct platform_device *pdev)
5555
if (!regmap)
5656
return -ENODEV;
5757

58-
led_node = device_get_named_child_node(dev->parent, "leds");
58+
struct fwnode_handle *led_node __free(fwnode_handle) =
59+
device_get_named_child_node(dev->parent, "leds");
5960
if (!led_node)
6061
return -ENODEV;
6162

0 commit comments

Comments
 (0)