Skip to content

Commit 509fe94

Browse files
SinkFindergregkh
authored andcommitted
memory: ti-aemif: Drop child node when jumping out loop
[ Upstream commit 94e9dd4 ] 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: 5a7c815 ("memory: ti-aemif: introduce AEMIF driver") Signed-off-by: Pan Bian <bianpan2016@163.com> Link: https://lore.kernel.org/r/20210121090359.61763-1-bianpan2016@163.com Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 63cb4aa commit 509fe94

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/memory/ti-aemif.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ static int aemif_probe(struct platform_device *pdev)
378378
*/
379379
for_each_available_child_of_node(np, child_np) {
380380
ret = of_aemif_parse_abus_config(pdev, child_np);
381-
if (ret < 0)
381+
if (ret < 0) {
382+
of_node_put(child_np);
382383
goto error;
384+
}
383385
}
384386
} else if (pdata && pdata->num_abus_data > 0) {
385387
for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
@@ -405,8 +407,10 @@ static int aemif_probe(struct platform_device *pdev)
405407
for_each_available_child_of_node(np, child_np) {
406408
ret = of_platform_populate(child_np, NULL,
407409
dev_lookup, dev);
408-
if (ret < 0)
410+
if (ret < 0) {
411+
of_node_put(child_np);
409412
goto error;
413+
}
410414
}
411415
} else if (pdata) {
412416
for (i = 0; i < pdata->num_sub_devices; i++) {

0 commit comments

Comments
 (0)