[PATCH] media: Fix resource leaks in for_each_child_of_node() loops

Hans Verkuil hverkuil-cisco at xs4all.nl
Wed Jul 19 00:41:52 PDT 2023


Hi Lu Hongfei,

Please add the driver name to the subject line: 'media: mdp3:'!

On 30/05/2023 11:45, Lu Hongfei wrote:
> for_each_child_of_node should have of_node_put() avoid resource leaks.
> 
> Signed-off-by: Lu Hongfei <luhongfei at vivo.com>
> ---
>  drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 3 +++
>  1 file changed, 3 insertions(+)
>  mode change 100644 => 100755 drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> 
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> index 19a4a085f73a..5a6a61d68cba
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> @@ -1128,6 +1128,7 @@ int mdp_comp_config(struct mdp_dev *mdp)
>  		comp = mdp_comp_create(mdp, node, id);
>  		if (IS_ERR(comp)) {
>  			ret = PTR_ERR(comp);
> +			of_node_put(node);

This is needed,

>  			goto err_init_comps;
>  		}
>  
> @@ -1137,6 +1138,8 @@ int mdp_comp_config(struct mdp_dev *mdp)
>  		pm_runtime_enable(comp->comp_dev);
>  	}
>  
> +	of_node_put(node);
> +

but not this one. The for_each_child_of_node loop ended, so node == NULL and
there is nothing to put.

Regards,

	Hans

>  	ret = mdp_comp_sub_create(mdp);
>  	if (ret)
>  		goto err_init_comps;




More information about the linux-arm-kernel mailing list