From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "javier.carrasco.cruz@gmail.com" <javier.carrasco.cruz@gmail.com>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"airlied@gmail.com" <airlied@gmail.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/3] drm/mediatek: ovl_adaptor: use scoped variant of for_each_child_of_node()
Date: Mon, 12 Aug 2024 06:02:22 +0000 [thread overview]
Message-ID: <d00fe6d1b49caf86949afe4b849dd1b4af3a287b.camel@mediatek.com> (raw)
In-Reply-To: <20240624-mtk_disp_ovl_adaptor_scoped-v1-3-9fa1e074d881@gmail.com>
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
>
next prev parent reply other threads:[~2024-08-12 6:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 16:43 [PATCH 0/3] drm/mediatek: fixes for ovl_adaptor Javier Carrasco
2024-06-24 16:43 ` [PATCH 1/3] drm/mediatek: ovl_adaptor: drop unused mtk_crtc.h header Javier Carrasco
2024-08-12 3:18 ` CK Hu (胡俊光)
2024-06-24 16:43 ` [PATCH 2/3] drm/mediatek: ovl_adaptor: add missing of_node_put() Javier Carrasco
2024-08-12 3:53 ` CK Hu (胡俊光)
2024-06-24 16:43 ` [PATCH 3/3] drm/mediatek: ovl_adaptor: use scoped variant of for_each_child_of_node() Javier Carrasco
2024-08-12 6:02 ` CK Hu (胡俊光) [this message]
2024-08-15 13:57 ` [PATCH 0/3] drm/mediatek: fixes for ovl_adaptor Chun-Kuang Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d00fe6d1b49caf86949afe4b849dd1b4af3a287b.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=Nancy.Lin@mediatek.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®