Skip to contentSkip to conversation

memory: ti-aemif: Drop child node when jumping out loop

PATCH Applied Pan Bian 2 participants 2 messages Jan 21, 2021 – Jan 25, 2021

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 memory: ti-aemif: Drop child node when jumping out loop

Call of_node_put() to decrement the reference count of the child node child_np when jumping out of the loop body of for_each_available_child_of_node(), which is a macro that increments and decrements the reference count of child node. If the loop is broken, the reference of the child node should be dropped manually.

Fixes 5a7c81547c1d ("memory: ti-aemif: introduce AEMIF driver")
---
 drivers/memory/ti-aemif.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/memory/ti-aemif.c +6 -2
index 159a16f5e7d6..51d20c2ccb75 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++) {
@@ -405,8 +407,10 @@ static int aemif_probe(struct platform_device *pdev)
 		for_each_available_child_of_node(np, child_np) {
 			ret = of_platform_populate(child_np, NULL,
 						   dev_lookup, dev);
-			if (ret < 0)
+			if (ret < 0) {
+				of_node_put(child_np);
 				goto error;
+			}
 		}
 	} else if (pdata) {
 		for (i = 0; i < pdata->num_sub_devices; i++) {
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Pan Bian

Call of_node_put() to decrement the reference count of the child node child_np when jumping out of the loop body of for_each_available_child_of_node(), which is a macro that increments and decrements the reference count of child node. If the loop is broken, the reference of the child node should be dropped manually.

Fixes 5a7c81547c1d ("memory: ti-aemif: introduce AEMIF driver")
---
 drivers/memory/ti-aemif.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Thanks, applied.

Best regards,
Krzysztof