hwmon: (tmp421) Add of_node_put() before return
authorWan Jiabing <wanjiabing@vivo.com>
Mon, 18 Oct 2021 12:15:37 +0000 (08:15 -0400)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 18 Oct 2021 14:23:21 +0000 (07:23 -0700)
Fix following coccicheck warning:
./drivers/hwmon/tmp421.c:416:1-23: WARNING: Function
for_each_child_of_node should have of_node_put() before return.

Early exits from for_each_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20211018121538.16482-1-wanjiabing@vivo.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/tmp421.c

index 31e95b5..1fd8d41 100644 (file)
@@ -418,8 +418,10 @@ static int tmp421_probe_from_dt(struct i2c_client *client, struct tmp421_data *d
                        continue;
 
                err = tmp421_probe_child_from_dt(client, child, data);
-               if (err)
+               if (err) {
+                       of_node_put(child);
                        return err;
+               }
        }
 
        return 0;