From: WenTao Liang <vulab@iscas.ac.cn>
To: chunkuang.hu@kernel.org, p.zabel@pengutronix.de,
airlied@gmail.com, simona@ffwll.ch, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com
Cc: dri-devel@lists.freedesktop.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
WenTao Liang <vulab@iscas.ac.cn>,
Greg KH <gregkh@linuxfoundation.org>,
stable@vger.kernel.org
Subject: [PATCH v2] drm/mediatek: fix of_node leak in mtk_drm_probe loop
Date: Sun, 28 Jun 2026 22:17:51 +0800 [thread overview]
Message-ID: <20260628141751.47090-1-vulab@iscas.ac.cn> (raw)
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);
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]);
private->comp_node[comp_id] = of_node_get(node);
/*
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-06-28 14:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 14:17 WenTao Liang [this message]
2026-07-16 2:06 ` CK 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=20260628141751.47090-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--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 \
/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®