From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: robh@kernel.org, dri-devel@lists.freedesktop.org,
devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 03/11] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration
Date: Thu, 09 Jul 2026 10:20:13 +0000 [thread overview]
Message-ID: <20260709102014.545EC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709100617.42583-4-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Wrong device pointer passed to devm_add_action_or_reset() for the audio codec platform device causes a leak and double-free.
- [High] Manual platform_device_unregister() calls in the devm_add_action_or_reset() error paths lead to double unregistrations.
--
--- Patch [3]: [PATCH v2 03/11] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration ---
commit ec9d95ddc19e68c697bea7b649dc680e85f406a8
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration
This commit attempts to fix platform device leaks during probe deferrals
by adding devm_add_action_or_reset() calls to automatically unregister
the HDMI codec and DisplayPort PHY platform devices.
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index eefbc7e0f9c8d..2c738c16dafab 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
[ ... ]
> @@ -2680,18 +2687,29 @@ static int mtk_dp_register_audio_driver(struct device *dev)
> .data = mtk_dp,
> .no_capture_mute = 1,
> };
> + int ret;
>
> mtk_dp->audio_pdev = platform_device_register_data(dev,
> HDMI_CODEC_DRV_NAME,
> PLATFORM_DEVID_AUTO,
> &codec_data,
> sizeof(codec_data));
> - return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev);
> + if (IS_ERR(mtk_dp->audio_pdev))
> + return PTR_ERR(mtk_dp->audio_pdev);
> +
> + ret = devm_add_action_or_reset(dev, mtk_dp_unregister_pdevs, mtk_dp->phy_dev);
^^^^^^^^^^^^^^^
[Severity: High]
Should this be passing mtk_dp->audio_pdev instead of mtk_dp->phy_dev?
Passing mtk_dp->phy_dev here registers a second unregister action for the phy
device, which could lead to a double-free on driver unbind, while leaving
the audio device leaked.
> + if (ret) {
> + platform_device_unregister(mtk_dp->audio_pdev);
[Severity: High]
Will this cause a double unregistration if devm_add_action_or_reset() fails?
Since devm_add_action_or_reset() automatically executes the action callback
(mtk_dp_unregister_pdevs) upon failure, wouldn't calling
platform_device_unregister() here unregister it a second time?
> + return dev_err_probe(dev, ret,
> + "Failed to add codec unregister devm action");
> + }
> + return 0;
> }
>
> static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
> {
> struct device *dev = mtk_dp->dev;
> + int ret;
>
> mtk_dp->phy_dev = platform_device_register_data(dev, "mediatek-dp-phy",
> PLATFORM_DEVID_AUTO,
> @@ -2701,6 +2719,13 @@ static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
> return dev_err_probe(dev, PTR_ERR(mtk_dp->phy_dev),
> "Failed to create device mediatek-dp-phy\n");
>
> + ret = devm_add_action_or_reset(dev, mtk_dp_unregister_pdevs, mtk_dp->phy_dev);
> + if (ret) {
> + platform_device_unregister(mtk_dp->phy_dev);
[Severity: High]
Similarly, does this result in a double unregistration if the devm action
fails to allocate?
devm_add_action_or_reset() will call mtk_dp_unregister_pdevs(mtk_dp->phy_dev)
internally if it returns an error, making this manual unregister redundant and
potentially unsafe.
> + return dev_err_probe(dev, ret,
> + "Failed to add phy unregister devm action");
> + }
> +
> mtk_dp_get_calibration_data(mtk_dp);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709100617.42583-1-angelogioacchino.delregno@collabora.com?part=3
next prev parent reply other threads:[~2026-07-09 10:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 10:06 [PATCH v2 00/11] drm: MediaTek DisplayPort cleanups and MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 01/11] dt-bindings: display: mediatek: dp: Deprecate nvmem efuse data AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 02/11] dt-bindings: display: mediatek: dp: Add compatible for MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 03/11] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration AngeloGioacchino Del Regno
2026-07-09 10:20 ` sashiko-bot [this message]
2026-07-09 10:06 ` [PATCH v2 04/11] drm/mediatek: mtk_dp: Clarify SMC eDP/DP video unmute commands AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 05/11] drm/mediatek: mtk_dp: Rework register offsets for proper PHY usage AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 06/11] drm/mediatek: mtk_dp: Use PHY API for PHY power sequences AngeloGioacchino Del Regno
2026-07-09 10:55 ` sashiko-bot
2026-07-09 10:06 ` [PATCH v2 07/11] drm/mediatek: mtk_dp: Add support for PHY from devicetree AngeloGioacchino Del Regno
2026-07-09 11:13 ` sashiko-bot
2026-07-09 10:06 ` [PATCH v2 08/11] drm/mediatek: mtk_dp: Move max link rate to SoC specific data AngeloGioacchino Del Regno
2026-07-09 10:06 ` [PATCH v2 09/11] drm/mediatek: mtk_dp: Add support for HotPlug Detection in DP AUX AngeloGioacchino Del Regno
2026-07-09 11:32 ` sashiko-bot
2026-07-09 10:06 ` [PATCH v2 10/11] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC AngeloGioacchino Del Regno
2026-07-09 11:49 ` sashiko-bot
2026-07-09 10:06 ` [PATCH v2 11/11] drm/mediatek: mtk_dp: Clarify XTAL freq and Debounce registers AngeloGioacchino Del Regno
2026-07-09 11:56 ` sashiko-bot
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=20260709102014.545EC1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).