iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of()
authorWei Yongjun <weiyongjun1@huawei.com>
Fri, 26 Aug 2016 14:31:50 +0000 (14:31 +0000)
committerJonathan Cameron <jic23@kernel.org>
Mon, 29 Aug 2016 18:51:17 +0000 (19:51 +0100)
When terminating for_each_child_of_node() iteration with
break or return, of_node_put() should be used to prevent
stale device node references from being left behind.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/ti-ads1015.c

index 1ef398770a1f2c2dcbc760f911b5064ea4950954..565e843e20b0d0ea4462a82854f3254619a6e8c8 100644 (file)
@@ -521,6 +521,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
                        if (pga > 6) {
                                dev_err(&client->dev, "invalid gain on %s\n",
                                        node->full_name);
+                               of_node_put(node);
                                return -EINVAL;
                        }
                }
@@ -531,6 +532,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
                                dev_err(&client->dev,
                                        "invalid data_rate on %s\n",
                                        node->full_name);
+                               of_node_put(node);
                                return -EINVAL;
                        }
                }