Commit a88f66d4 authored by Vasyl Gomonovych's avatar Vasyl Gomonovych Committed by Santosh Shilimkar

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: default avatarVasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
parent 5c8fe583
...@@ -758,6 +758,7 @@ static int knav_dma_probe(struct platform_device *pdev) ...@@ -758,6 +758,7 @@ static int knav_dma_probe(struct platform_device *pdev)
for_each_child_of_node(node, child) { for_each_child_of_node(node, child) {
ret = dma_init(node, child); ret = dma_init(node, child);
if (ret) { if (ret) {
of_node_put(child);
dev_err(&pdev->dev, "init failed with %d\n", ret); dev_err(&pdev->dev, "init failed with %d\n", ret);
break; break;
} }
......
...@@ -1087,6 +1087,7 @@ static int knav_queue_setup_regions(struct knav_device *kdev, ...@@ -1087,6 +1087,7 @@ static int knav_queue_setup_regions(struct knav_device *kdev,
for_each_child_of_node(regions, child) { for_each_child_of_node(regions, child) {
region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL); region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL);
if (!region) { if (!region) {
of_node_put(child);
dev_err(dev, "out of memory allocating region\n"); dev_err(dev, "out of memory allocating region\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1399,6 +1400,7 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev, ...@@ -1399,6 +1400,7 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
for_each_child_of_node(qmgrs, child) { for_each_child_of_node(qmgrs, child) {
qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL); qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL);
if (!qmgr) { if (!qmgr) {
of_node_put(child);
dev_err(dev, "out of memory allocating qmgr\n"); dev_err(dev, "out of memory allocating qmgr\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1498,6 +1500,7 @@ static int knav_queue_init_pdsps(struct knav_device *kdev, ...@@ -1498,6 +1500,7 @@ static int knav_queue_init_pdsps(struct knav_device *kdev,
for_each_child_of_node(pdsps, child) { for_each_child_of_node(pdsps, child) {
pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL); pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL);
if (!pdsp) { if (!pdsp) {
of_node_put(child);
dev_err(dev, "out of memory allocating pdsp\n"); dev_err(dev, "out of memory allocating pdsp\n");
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment