Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: ti: knav_qmss: Put refcount for dev node in failure case

for_each_child_of_node increases refcount for each device_node and decreases previous one
in a loop, but in case jump out of a loop current node refcount has no chnase for decreases
so requires an of_node_put for jupm out cases.

Fix based on raport from
scripts/coccinelle/iterators/for_each_child.cocci

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

authored by

Vasyl Gomonovych and committed by
Santosh Shilimkar
a88f66d4 5c8fe583

+4
+1
drivers/soc/ti/knav_dma.c
··· 758 758 for_each_child_of_node(node, child) { 759 759 ret = dma_init(node, child); 760 760 if (ret) { 761 + of_node_put(child); 761 762 dev_err(&pdev->dev, "init failed with %d\n", ret); 762 763 break; 763 764 }
+3
drivers/soc/ti/knav_qmss_queue.c
··· 1087 1087 for_each_child_of_node(regions, child) { 1088 1088 region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL); 1089 1089 if (!region) { 1090 + of_node_put(child); 1090 1091 dev_err(dev, "out of memory allocating region\n"); 1091 1092 return -ENOMEM; 1092 1093 } ··· 1400 1399 for_each_child_of_node(qmgrs, child) { 1401 1400 qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL); 1402 1401 if (!qmgr) { 1402 + of_node_put(child); 1403 1403 dev_err(dev, "out of memory allocating qmgr\n"); 1404 1404 return -ENOMEM; 1405 1405 } ··· 1500 1498 for_each_child_of_node(pdsps, child) { 1501 1499 pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL); 1502 1500 if (!pdsp) { 1501 + of_node_put(child); 1503 1502 dev_err(dev, "out of memory allocating pdsp\n"); 1504 1503 return -ENOMEM; 1505 1504 }