]> Git Repo - linux.git/commitdiff
leds: netxbig: Add of_node_put() in netxbig_leds_get_of_pdata()
authorNishka Dasgupta <[email protected]>
Mon, 29 Jul 2019 06:53:56 +0000 (12:23 +0530)
committerJacek Anaszewski <[email protected]>
Mon, 29 Jul 2019 19:12:54 +0000 (21:12 +0200)
The variable gpio_ext_np in the function netxbig_leds_get_of_pdata takes
the value returned by of_parse_phandle; hence, it must be put in order
to prevent a memory leak. Add an of_node_put for gpio_ext_np before a
return statement, and move a pre-existing of_node_put statement to right
after the last usage of this variable.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Signed-off-by: Jacek Anaszewski <[email protected]>
drivers/leds/leds-netxbig.c

index 0944cb111c34e006eab4c41415a4091fdbad761b..14ef4ccdda3a81205bf8f60a885992d39fd9ab38 100644 (file)
@@ -428,12 +428,14 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
        }
 
        gpio_ext = devm_kzalloc(dev, sizeof(*gpio_ext), GFP_KERNEL);
-       if (!gpio_ext)
+       if (!gpio_ext) {
+               of_node_put(gpio_ext_np);
                return -ENOMEM;
+       }
        ret = gpio_ext_get_of_pdata(dev, gpio_ext_np, gpio_ext);
+       of_node_put(gpio_ext_np);
        if (ret)
                return ret;
-       of_node_put(gpio_ext_np);
        pdata->gpio_ext = gpio_ext;
 
        /* Timers (optional) */
This page took 0.04345 seconds and 4 git commands to generate.