leds: netxbig: Fix refcount leak in netxbig_leds_get_of_pdata
PATCH 1/1 leds: netxbig: Fix refcount leak in netxbig_leds_get_of_pdata
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. When of_find_device_by_node() fails, of_node_put() is missing.
Fixes 9af512e81964 ("leds: netxbig: Convert to use GPIO descriptors")
Signed-off-by Miaoqian Lin <[email protected]>
--- drivers/leds/leds-netxbig.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/leds-netxbig.c +1 -0
@@ -441,6 +441,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, gpio_ext_pdev =of_find_device_by_node (gpio_ext_np);if (!gpio_ext_pdev) {dev_err (dev,"Failed to find platform device for gpio-ext\n" ); +of_node_put (gpio_ext_np);return -ENODEV ; } gpio_ext_dev = &gpio_ext_pdev->dev;
Signature · 1 line
2.25.1
Hi!
Quoted 3 lines
of_parse_phandle()returns a node pointer with refcount incremented, we should useof_node_put()on it when not needed anymore. Whenof_find_device_by_node()fails,of_node_put()is missing.
Can you take a look at the code and simplify it? AFAICT the node_put should go right after
gpio_ext_pdev = of_find_device_by_node(gpio_ext_np);
. Best regards,
Pavel
Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.