Skip to contentSkip to conversation

memory: ti-aemif: Add of_node_put() before goto

PATCH New Nishka Dasgupta 1 participant 1 message Jul 9, 2019

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

PATCH 1/1 memory: ti-aemif: Add of_node_put() before goto

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
 drivers/memory/ti-aemif.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/memory/ti-aemif.c +3 -1
index db526dbf71ee..9fc80aa89f64 100644
@@ -378,8 +378,10 @@ static int aemif_probe(struct platform_device *pdev)
 		 */
 		for_each_available_child_of_node(np, child_np) {
 			ret = of_aemif_parse_abus_config(pdev, child_np);
-			if (ret < 0)
+			if (ret < 0) {
+				of_node_put(child_np);
 				goto error;
+			}
 		}
 	} else if (pdata && pdata->num_abus_data > 0) {
 		for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
Signature · 1 line
2.19.1