From: Guangshuo Li <liguangshuo@mail.sdu.edu.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: ck.hu@mediatek.com, amergnat@baylibre.com,
dri-devel@lists.freedesktop.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drm/mediatek: dp: Fix potential stale PHY device on probe failure
Date: Wed, 2 Dec 2026 19:28:35 +0800 [thread overview]
Message-ID: <20261202-85cdeb22ca-drm-mediatek@mail.sdu.edu.cn> (raw)
The DP PHY child keeps a pointer to the parent regmap. A later DP probe
failure releases that regmap but leaves the child registered, allowing
its PHY operations to access freed storage.
Manage child removal with the parent so it also runs on probe failure,
before the parent regmap is released.
This issue was found by our static analysis tool under development.
Fixes: caf2ae486742 ("drm/mediatek: dp: Add support for embedded DisplayPort aux-bus")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 974c4fff6fd3..b3c8b1088c47 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2688,6 +2688,11 @@ static int mtk_dp_register_audio_driver(struct device *dev)
return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev);
}
+static void mtk_dp_unregister_phy(void *data)
+{
+ platform_device_unregister(data);
+}
+
static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
{
struct device *dev = mtk_dp->dev;
@@ -2708,7 +2713,7 @@ static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
return dev_err_probe(dev, PTR_ERR(mtk_dp->phy), "Failed to get phy\n");
}
- return 0;
+ return devm_add_action_or_reset(dev, mtk_dp_unregister_phy, mtk_dp->phy_dev);
}
static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux)
@@ -2869,7 +2874,6 @@ static void mtk_dp_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (mtk_dp->data->bridge_type != DRM_MODE_CONNECTOR_eDP)
timer_delete_sync(&mtk_dp->debounce_timer);
- platform_device_unregister(mtk_dp->phy_dev);
if (mtk_dp->audio_pdev)
platform_device_unregister(mtk_dp->audio_pdev);
}
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
reply other threads:[~2026-12-02 11:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261202-85cdeb22ca-drm-mediatek@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=airlied@gmail.com \
--cc=amergnat@baylibre.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=ck.hu@mediatek.com \
--cc=dri-devel@lists.freedesktop.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 \
/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®