leds: max5970: fix unreleased fwnode_handle in probe function
PATCH v2 1/1 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.
---
Changes in v2:
- Squash patches for mainline solution without intermediate steps.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/leds/leds-max5970.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/leds/leds-max5970.c +3 -2
@@ -45,7 +45,7 @@ static int max5970_led_set_brightness(struct led_classdev *cdev,static int max5970_led_probe (struct platform_device *pdev) { -struct fwnode_handle *led_node, *child; +struct fwnode_handle *child;struct device *dev = &pdev->dev;struct regmap *regmap;struct max5970_led *ddata;
@@ -55,7 +55,8 @@ static int max5970_led_probe(struct platform_device *pdev)if (!regmap)return -ENODEV ; - led_node =device_get_named_child_node (dev->parent,"leds" ); + struct fwnode_handle *led_node __free(fwnode_handle) = +device_get_named_child_node (dev->parent,"leds" );if (!led_node)return -ENODEV ;
---
base-commit: f9f24ca362a4d84dd8aeb4b8f3ec28cb6c43dd06
change-id: 20241019-max5970-of_node_put-939b004f57d2
Best regards,
Signature · 1 line
Javier Carrasco <[email protected]>
Re: (subset) [PATCH v2] leds: max5970: fix unreleased fwnode_handle in probe function
Quoted 8 lines · Javier Carrasco
An object initialized via
device_get_named_child_node()requires calls tofwnode_handle_put()when it is no longer required to avoid leaking memory.Add the automatic cleanup facility for '
led_node' to ensure thatfwnode_handle_put()is called in all execution paths.[...]
Applied, thanks!
[1/1] leds: max5970: fix unreleased fwnode_handle in probe function
commit: 02f58f97419c828f58e30f24f54395ac9be159c0
--
Lee Jones [李琼斯]