Skip to contentSkip to conversation

iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of()

PATCH Applied Wei Yongjun 2 participants 2 messages Aug 26, 2016 – Aug 29, 2016 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of()

From: Wei Yongjun <[email protected]>

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.

---
 drivers/iio/adc/ti-ads1015.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/adc/ti-ads1015.c +2 -0
index 066abaf..cde6f13 100644
@@ -522,6 +522,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;
 			}
 		}
@@ -532,6 +533,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;
 			}
 		}
maintainer Applied
#1 lore raw
Quoted 9 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

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.

Thanks,

Applied to the togreg branch of iio.git. Initially pushed out as testing for the autobuilders to play with it.

Jonathan

Quoted 27 lines
---
 drivers/iio/adc/ti-ads1015.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/adc/ti-ads1015.c +2 -0
index 066abaf..cde6f13 100644
@@ -522,6 +522,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;
 			}
 		}
@@ -532,6 +533,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;
 			}
 		}