From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"vulab@iscas.ac.cn" <vulab@iscas.ac.cn>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"airlied@gmail.com" <airlied@gmail.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"simona@ffwll.ch" <simona@ffwll.ch>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] drm/mediatek: fix of_node leak in mtk_drm_probe loop
Date: Thu, 16 Jul 2026 02:06:59 +0000 [thread overview]
Message-ID: <eb2062305868dca02d34d8f09caddbc8a91e5cd5.camel@mediatek.com> (raw)
In-Reply-To: <20260628141751.47090-1-vulab@iscas.ac.cn>
On Sun, 2026-06-28 at 22:17 +0800, WenTao Liang wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> In the for_each_child_of_node loop, private->comp_node[comp_id] and
> private->mutex_node are assigned via of_node_get without first releasing
> any previously stored reference for the same index. When the same comp_id
> or mmsys_id matches multiple nodes, earlier node references are
> overwritten and permanently leaked.
>
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys support")
> Cc: stable@vger.kernel.org
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
> ---
> Changes in v2:
> - Fix patch format based on reviewer feedback
> ---
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index c86a3f54f35b..58860f7071a9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -1138,6 +1138,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
>
> id = of_alias_get_id(node, "mutex");
> if (id < 0 || id == private->data->mmsys_id) {
> + of_node_put(private->mutex_node);
This driver has an assumption that one mutex_node in one mmsys pipeline.
If more than one, there should be some error happen.
It's not necessary to keep going.
Simply print error message and return error code.
> private->mutex_node = of_node_get(node);
> dev_dbg(dev, "get mutex for mmsys %d", private->data->mmsys_id);
> }
> @@ -1154,6 +1155,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
> if (!mtk_drm_find_mmsys_comp(private, comp_id))
> continue;
>
> + of_node_put(private->comp_node[comp_id]);
This driver has an assumption that every comp_id only exist once in device tree.
If more than one, there should be some error happen.
It's not necessary to keep going.
Simply print error message and return error code.
Regards,
CK
> private->comp_node[comp_id] = of_node_get(node);
>
> /*
> --
> 2.39.5 (Apple Git-154)
>
prev parent reply other threads:[~2026-07-16 2:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 14:17 [PATCH v2] drm/mediatek: fix of_node leak in mtk_drm_probe loop WenTao Liang
2026-07-16 2:06 ` CK Hu (胡俊光) [this message]
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=eb2062305868dca02d34d8f09caddbc8a91e5cd5.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--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 \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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