Skip to contentSkip to conversation

hwmon: (nct7802) Add of_node_put() before return

PATCH Applied Wan Jiabing 2 participants 2 messages Oct 29, 2021 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (nct7802) Add of_node_put() before return

Fix following coccicheck warning:
./drivers/hwmon/nct7802.c:1152:2-24: 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.

---
 drivers/hwmon/nct7802.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/nct7802.c +3 -1
index d56f78327619..d1eeef02b6dc 100644
@@ -1152,8 +1152,10 @@ static int nct7802_configure_channels(struct device *dev,
 		for_each_child_of_node(dev->of_node, node) {
 			err = nct7802_get_channel_config(dev, node, &mode_mask,
 							 &mode_val);
-			if (err)
+			if (err) {
+				of_node_put(node);
 				return err;
+			}
 		}
 	}
 
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Wan Jiabing

Fix following coccicheck warning:
./drivers/hwmon/nct7802.c:1152:2-24: 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.

Applied.

Thanks,
Guenter

Quoted 20 lines
---
 drivers/hwmon/nct7802.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/nct7802.c +3 -1
index d56f78327619..d1eeef02b6dc 100644
@@ -1152,8 +1152,10 @@ static int nct7802_configure_channels(struct device *dev,
 		for_each_child_of_node(dev->of_node, node) {
 			err = nct7802_get_channel_config(dev, node, &mode_mask,
 							 &mode_val);
-			if (err)
+			if (err) {
+				of_node_put(node);
 				return err;
+			}
 		}
 	}