Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return in two places. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta <nishkadg.linux@xxxxxxxxx> --- drivers/hwmon/ads1015.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c index 3727a3762eb8..a0d62f6fa4b6 100644 --- a/drivers/hwmon/ads1015.c +++ b/drivers/hwmon/ads1015.c @@ -195,6 +195,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client) if (pga > 6) { dev_err(&client->dev, "invalid gain on %pOF\n", node); + of_node_put(node); return -EINVAL; } } @@ -204,6 +205,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client) if (data_rate > 7) { dev_err(&client->dev, "invalid data_rate on %pOF\n", node); + of_node_put(node); return -EINVAL; } } -- 2.19.1