diff options
author | Deepak R Varma <drv@mailo.com> | 2023-02-11 12:09:50 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2023-05-25 16:21:19 +0200 |
commit | b8ed1ceb4a2653a2d5529b3afb79343d77efb3ce (patch) | |
tree | 08946c3c60940e2abb03e504cfaf5a4354f0c186 /drivers | |
parent | media: platform: rzg2l-cru: rzg2l-csi2: Enclose the macro in parentheses (diff) | |
download | linux-b8ed1ceb4a2653a2d5529b3afb79343d77efb3ce.tar.xz linux-b8ed1ceb4a2653a2d5529b3afb79343d77efb3ce.zip |
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: Deepak R Varma <drv@mailo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c index 19a4a085f73a..a605e80c7dc3 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c @@ -1035,6 +1035,7 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp) { struct device *dev = &mdp->pdev->dev; struct device_node *node, *parent; + int ret = 0; parent = dev->of_node->parent; @@ -1060,16 +1061,22 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp) dev_err(dev, "Fail to get sub comp. id: type %d alias %d\n", type, alias_id); - return -EINVAL; + ret = -EINVAL; + goto err_free_node; } mdp_comp_alias_id[type]++; comp = mdp_comp_create(mdp, node, id); - if (IS_ERR(comp)) - return PTR_ERR(comp); + if (IS_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) |