[PATCH] media: platform: mtk-mdp3: add missing call to of_node_put()

Hans Verkuil hverkuil-cisco at xs4all.nl
Fri Nov 18 06:43:02 PST 2022


On 11/13/22 12:05, wangkailong at jari.cn wrote:
> Fix the following coccicheck warning:
> 
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c:892:1-23: WARNING:
> Function "for_each_child_of_node" should have of_node_put() before
> return around line 914.
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c:892:1-23: WARNING:
> Function "for_each_child_of_node" should have of_node_put() before
> return around line 920.
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c:951:1-23: WARNING:
> Function "for_each_child_of_node" should have of_node_put() before
> return around line 993.
> 
> Signed-off-by: KaiLong Wang <wangkailong at jari.cn>
> ---
>  drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> index d3eaf8884412..4162fc732f38 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> @@ -908,6 +908,7 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp)
>  		alias_id = mdp_comp_alias_id[type];
>  		id = mdp_comp_get_id(type, alias_id);
>  		if (id < 0) {
> +			of_node_put(node);
>  			dev_err(dev,
>  				"Fail to get sub comp. id: type %d alias %d\n",
>  				type, alias_id);
> @@ -916,8 +917,10 @@ static int mdp_comp_sub_create(struct mdp_dev *mdp)
>  		mdp_comp_alias_id[type]++;
>  
>  		comp = mdp_comp_create(mdp, node, id);
> -		if (IS_ERR(comp))
> +		if (IS_ERR(comp)) {
> +			of_node_put(node);
>  			return PTR_ERR(comp);
> +		}
>  	}
>  
>  	return 0;
> @@ -988,6 +991,7 @@ int mdp_comp_config(struct mdp_dev *mdp)
>  
>  		pdev = of_find_device_by_node(node);
>  		if (!pdev) {
> +			of_node_put(node);
>  			dev_warn(dev, "can't find platform device of node:%s\n",
>  				 node->name);
>  			return -ENODEV;

There is a 'goto err_init_comps;' in this function as well that needs
an of_node_put(node); line.

Can you make a v2?

Regards,

	Hans



More information about the Linux-mediatek mailing list