Commit b8ed1ceb authored by Deepak R Varma's avatar Deepak R Varma Committed by Hans Verkuil

media: platform: mtk-mdp3: release node reference before returning

The iterator for_each_child_of_node() increments the refcount of the
child node it is processing. Release such a reference when the loop
needs to break due to an error during its execution.
Issue identified using for_each_child.cocci Coccinelle semantic patch.
Signed-off-by: default avatarDeepak R Varma <drv@mailo.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent e5f29bb9
...@@ -1035,6 +1035,7 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp) ...@@ -1035,6 +1035,7 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp)
{ {
struct device *dev = &mdp->pdev->dev; struct device *dev = &mdp->pdev->dev;
struct device_node *node, *parent; struct device_node *node, *parent;
int ret = 0;
parent = dev->of_node->parent; parent = dev->of_node->parent;
...@@ -1060,16 +1061,22 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp) ...@@ -1060,16 +1061,22 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp)
dev_err(dev, dev_err(dev,
"Fail to get sub comp. id: type %d alias %d\n", "Fail to get sub comp. id: type %d alias %d\n",
type, alias_id); type, alias_id);
return -EINVAL; ret = -EINVAL;
goto err_free_node;
} }
mdp_comp_alias_id[type]++; mdp_comp_alias_id[type]++;
comp = mdp_comp_create(mdp, node, id); comp = mdp_comp_create(mdp, node, id);
if (IS_ERR(comp)) if (IS_ERR(comp)) {
return PTR_ERR(comp); ret = PTR_ERR(comp);
goto err_free_node;
}
} }
return ret;
return 0; err_free_node:
of_node_put(node);
return ret;
} }
void mdp_comp_destroy(struct mdp_dev *mdp) void mdp_comp_destroy(struct mdp_dev *mdp)
......
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