diff mbox series

leds: netxbig: fix an OF node reference leak in netxbig_leds_get_of_pdata()

Message ID 20241216074923.628509-1-joe@pf.is.s.u-tokyo.ac.jp
State New
Headers show
Series leds: netxbig: fix an OF node reference leak in netxbig_leds_get_of_pdata() | expand

Commit Message

Joe Hattori Dec. 16, 2024, 7:49 a.m. UTC
netxbig_leds_get_of_pdata() does not release the OF node obtained by
of_parse_phandle() when of_find_device_by_node() fails. Add an
of_node_put() call to fix the leak.

This bug was found by an experimental static analysis tool that I am
developing.

Fixes: 9af512e81964 ("leds: netxbig: Convert to use GPIO descriptors")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
---
 drivers/leds/leds-netxbig.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Lee Jones Dec. 17, 2024, 3:01 p.m. UTC | #1
On Mon, 16 Dec 2024 16:49:23 +0900, Joe Hattori wrote:
> netxbig_leds_get_of_pdata() does not release the OF node obtained by
> of_parse_phandle() when of_find_device_by_node() fails. Add an
> of_node_put() call to fix the leak.
> 
> This bug was found by an experimental static analysis tool that I am
> developing.
> 
> [...]

Applied, thanks!

[1/1] leds: netxbig: fix an OF node reference leak in netxbig_leds_get_of_pdata()
      commit: 0508316be63bb735f59bdc8fe4527cadb62210ca

--
Lee Jones [李琼斯]
diff mbox series

Patch

diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
index af5a908b8d9e..e95287416ef8 100644
--- a/drivers/leds/leds-netxbig.c
+++ b/drivers/leds/leds-netxbig.c
@@ -439,6 +439,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) {
+		of_node_put(gpio_ext_np);
 		dev_err(dev, "Failed to find platform device for gpio-ext\n");
 		return -ENODEV;
 	}