]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
leds: netxbig: Fix an OF node reference leak in netxbig_leds_get_of_pdata()
authorJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Mon, 16 Dec 2024 07:49:23 +0000 (16:49 +0900)
committerLee Jones <lee@kernel.org>
Tue, 17 Dec 2024 15:01:11 +0000 (15:01 +0000)
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>
Link: https://lore.kernel.org/r/20241216074923.628509-1-joe@pf.is.s.u-tokyo.ac.jp
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-netxbig.c

index af5a908b8d9edd5034573a71774b471146d2cfcf..e95287416ef879f322398ea3c8269b78504ed4ed 100644 (file)
@@ -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;
        }