Skip to contentSkip to conversation

OPP: call of_node_put() on error path in _bandwidth_supported()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 6, 2022 – Apr 11, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OPP: call of_node_put() on error path in _bandwidth_supported()

This code does not call of_node_put(opp_np) if of_get_next_available_child() returns NULL. But it should.

Fixes 45679f9b508f ("opp: Don't parse icc paths unnecessarily")
---
 drivers/opp/of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +1 -1
index 440ab5a03df9..95b184fc3372 100644
@@ -437,11 +437,11 @@ static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table)
 
 	/* Checking only first OPP is sufficient */
 	np = of_get_next_available_child(opp_np, NULL);
+	of_node_put(opp_np);
 	if (!np) {
 		dev_err(dev, "OPP table empty\n");
 		return -EINVAL;
 	}
-	of_node_put(opp_np);
 
 	prop = of_find_property(np, "opp-peak-kBps", NULL);
 	of_node_put(np);
Signature · 1 line
2.20.1
Applied
#1 lore raw
Quoted 16 lines · Dan Carpenter

This code does not call of_node_put(opp_np) if of_get_next_available_child() returns NULL. But it should.

Fixes 45679f9b508f ("opp: Don't parse icc paths unnecessarily")
---
 drivers/opp/of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +0 -0
index 440ab5a03df9..95b184fc3372 100644
@@ -437,11 +437,11 @@ static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table)
 
 	/* Checking only first OPP is sufficient */

drivers/opp/of.c static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) · line 447

Quoted 10 lines
drivers/opp/of.c +1 -1
 	np = of_get_next_available_child(opp_np, NULL);
+	of_node_put(opp_np);
 	if (!np) {
 		dev_err(dev, "OPP table empty\n");
 		return -EINVAL;
 	}
-	of_node_put(opp_np);
 
 	prop = of_find_property(np, "opp-peak-kBps", NULL);
 	of_node_put(np);

Applied. Thanks.

Signature · 1 line
viresh