<html><body><p>
<pre>
Hi, Javier:

On Mon, 2024-06-24 at 18:43 +0200, Javier Carrasco wrote:
>
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> In order to avoid potential memory leaks if new error paths are added
> without a call to of_node_put(), use for_each_child_of_node_scoped()
> instead of for_each_child_of_node(). The former automatically decrements
> the refcount when the child goes out of scope, which removes the need
> for explicit calls to of_node_put().

Reviewed-by: CK Hu <ck.hu@mediatek.com>

>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> index 3faf26a55e77..aec927cce468 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
> @@ -493,12 +493,12 @@ static int compare_of(struct device *dev, void *data)
> static int ovl_adaptor_comp_init(struct device *dev, struct component_match **match)
> {
> struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev);
> -struct device_node *node, *parent;
> +struct device_node *parent;
> struct platform_device *comp_pdev;
>
> parent = dev->parent->parent->of_node->parent;
>
> -for_each_child_of_node(parent, node) {
> +for_each_child_of_node_scoped(parent, node) {
> const struct of_device_id *of_id;
> enum mtk_ovl_adaptor_comp_type type;
> int id;
> @@ -522,10 +522,8 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma
> }
>
> comp_pdev = of_find_device_by_node(node);
> -if (!comp_pdev) {
> -of_node_put(node);
> +if (!comp_pdev)
> return -EPROBE_DEFER;
> -}
>
> priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
>
>
> --
> 2.40.1
>

</pre>
</p></body></html><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->