From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: neil.armstrong@linaro.org, vkoul@kernel.org,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
olteanv@gmail.com, robh@kernel.org, conor+dt@kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/12] phy: phy-mtk-dp: Allow probing with devicetree match
Date: Wed, 01 Jul 2026 12:30:03 +0000 [thread overview]
Message-ID: <20260701123003.B65211F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701122008.19509-4-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] The return value of `pm_runtime_get_sync()` is ignored, which can lead to hardware register accesses on an unpowered device.
- [Medium] Missing `.remove` callback leaves PM runtime enabled and usage counter unbalanced on driver unbind.
Pre-existing issues:
- [High] Missing `phy_remove_lookup()` causes a memory leak and a dangling pointer in the global PHY lookup list.
- [High] Unconditional dereference of `dev->platform_data` before validating it.
--
commit e3a3844cc6f977665174375e23735f789c04a772
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
phy: phy-mtk-dp: Allow probing with devicetree match
This commit introduces a devicetree match table to decouple the DP PHY driver
from the DP IP driver. It adds an OF PHY provider and MMIO regmap registration
for the devicetree case, while maintaining a legacy probe path for older
devicetrees without a separate PHY node.
> diff --git a/drivers/phy/mediatek/phy-mtk-dp.c b/drivers/phy/mediatek/phy-mtk-dp.c
> index bf7b3a95e72d2..98e05fe05ce3b 100644
> --- a/drivers/phy/mediatek/phy-mtk-dp.c
> +++ b/drivers/phy/mediatek/phy-mtk-dp.c
[ ... ]
> @@ -160,43 +161,92 @@ static const struct phy_ops mtk_dp_phy_dev_ops = {
> .owner = THIS_MODULE,
> };
>
> +static int mtk_dp_phy_legacy_probe(struct platform_device *pdev, struct mtk_dp_phy *dp_phy)
> +{
> + struct device *dev = &pdev->dev;
> + struct phy *phy;
> +
> + dp_phy->regmap = *(struct regmap **)dev->platform_data;
[Severity: High]
This is a pre-existing issue, but does this code unconditionally dereference
dev->platform_data before verifying it is not NULL?
If the platform device is instantiated without platform data, would this
dereference cause a kernel panic before the subsequent check for
!dp_phy->regmap can execute?
> + if (!dp_phy->regmap)
> + return dev_err_probe(dev, -EINVAL, "No platform data available\n");
> +
> + phy = devm_phy_create(dev, NULL, &mtk_dp_phy_dev_ops);
> + if (IS_ERR(phy))
> + return dev_err_probe(dev, PTR_ERR(phy),
> + "Failed to create DP PHY\n");
> +
> + phy_set_drvdata(phy, dp_phy);
> + phy_create_lookup(phy, "dp", dev_name(dev));
[Severity: High]
This isn't a bug introduced by this patch, but does this leak the lookup
entry and create a dangling pointer?
phy_create_lookup() dynamically allocates a phy_lookup structure and links it
into the global phys list. Since there is no driver .remove callback calling
phy_remove_lookup(), when the driver unbinds, the devres-managed phy is freed
while still in the global list, which could cause a use-after-free when other
drivers call phy_find().
> +
> + return 0;
> +}
> +
[ ... ]
> static int mtk_dp_phy_probe(struct platform_device *pdev)
> {
[ ... ]
> + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> + if (IS_ERR(provider))
> + return PTR_ERR(provider);
> +
> + pm_runtime_enable(dev);
> + pm_runtime_get_sync(dev);
[Severity: High]
Is it safe to ignore the return value of pm_runtime_get_sync() here?
If the generic power domain or clock fails to enable, pm_runtime_get_sync()
will return a negative error code. Without checking this, the PHY provider is
registered even if the hardware is off, which could lead to a synchronous
external abort when attempting to write to the MMIO registers later.
>
> return 0;
> }
>
> +static const struct of_device_id mtk_dp_phy_of_match[] = {
> + { .compatible = "mediatek,mt8195-dp-phy" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mtk_dp_phy_of_match);
> +
> static struct platform_driver mtk_dp_phy_driver = {
> .probe = mtk_dp_phy_probe,
> .driver = {
> .name = "mediatek-dp-phy",
> + .of_match_table = mtk_dp_phy_of_match,
> },
> };
[Severity: Medium]
Does this driver need a .remove callback to clean up the PM runtime state?
Since pm_runtime_enable() and pm_runtime_get_sync() are called in probe
without devm_ handlers or registered teardown actions, unbinding the driver
appears to leak the usage counter and leave PM runtime permanently enabled.
> module_platform_driver(mtk_dp_phy_driver);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701122008.19509-1-angelogioacchino.delregno@collabora.com?part=3
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: neil.armstrong@linaro.org, vkoul@kernel.org,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
olteanv@gmail.com, robh@kernel.org, conor+dt@kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/12] phy: phy-mtk-dp: Allow probing with devicetree match
Date: Wed, 01 Jul 2026 12:30:03 +0000 [thread overview]
Message-ID: <20260701123003.B65211F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701122008.19509-4-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] The return value of `pm_runtime_get_sync()` is ignored, which can lead to hardware register accesses on an unpowered device.
- [Medium] Missing `.remove` callback leaves PM runtime enabled and usage counter unbalanced on driver unbind.
Pre-existing issues:
- [High] Missing `phy_remove_lookup()` causes a memory leak and a dangling pointer in the global PHY lookup list.
- [High] Unconditional dereference of `dev->platform_data` before validating it.
--
commit e3a3844cc6f977665174375e23735f789c04a772
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
phy: phy-mtk-dp: Allow probing with devicetree match
This commit introduces a devicetree match table to decouple the DP PHY driver
from the DP IP driver. It adds an OF PHY provider and MMIO regmap registration
for the devicetree case, while maintaining a legacy probe path for older
devicetrees without a separate PHY node.
> diff --git a/drivers/phy/mediatek/phy-mtk-dp.c b/drivers/phy/mediatek/phy-mtk-dp.c
> index bf7b3a95e72d2..98e05fe05ce3b 100644
> --- a/drivers/phy/mediatek/phy-mtk-dp.c
> +++ b/drivers/phy/mediatek/phy-mtk-dp.c
[ ... ]
> @@ -160,43 +161,92 @@ static const struct phy_ops mtk_dp_phy_dev_ops = {
> .owner = THIS_MODULE,
> };
>
> +static int mtk_dp_phy_legacy_probe(struct platform_device *pdev, struct mtk_dp_phy *dp_phy)
> +{
> + struct device *dev = &pdev->dev;
> + struct phy *phy;
> +
> + dp_phy->regmap = *(struct regmap **)dev->platform_data;
[Severity: High]
This is a pre-existing issue, but does this code unconditionally dereference
dev->platform_data before verifying it is not NULL?
If the platform device is instantiated without platform data, would this
dereference cause a kernel panic before the subsequent check for
!dp_phy->regmap can execute?
> + if (!dp_phy->regmap)
> + return dev_err_probe(dev, -EINVAL, "No platform data available\n");
> +
> + phy = devm_phy_create(dev, NULL, &mtk_dp_phy_dev_ops);
> + if (IS_ERR(phy))
> + return dev_err_probe(dev, PTR_ERR(phy),
> + "Failed to create DP PHY\n");
> +
> + phy_set_drvdata(phy, dp_phy);
> + phy_create_lookup(phy, "dp", dev_name(dev));
[Severity: High]
This isn't a bug introduced by this patch, but does this leak the lookup
entry and create a dangling pointer?
phy_create_lookup() dynamically allocates a phy_lookup structure and links it
into the global phys list. Since there is no driver .remove callback calling
phy_remove_lookup(), when the driver unbinds, the devres-managed phy is freed
while still in the global list, which could cause a use-after-free when other
drivers call phy_find().
> +
> + return 0;
> +}
> +
[ ... ]
> static int mtk_dp_phy_probe(struct platform_device *pdev)
> {
[ ... ]
> + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> + if (IS_ERR(provider))
> + return PTR_ERR(provider);
> +
> + pm_runtime_enable(dev);
> + pm_runtime_get_sync(dev);
[Severity: High]
Is it safe to ignore the return value of pm_runtime_get_sync() here?
If the generic power domain or clock fails to enable, pm_runtime_get_sync()
will return a negative error code. Without checking this, the PHY provider is
registered even if the hardware is off, which could lead to a synchronous
external abort when attempting to write to the MMIO registers later.
>
> return 0;
> }
>
> +static const struct of_device_id mtk_dp_phy_of_match[] = {
> + { .compatible = "mediatek,mt8195-dp-phy" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mtk_dp_phy_of_match);
> +
> static struct platform_driver mtk_dp_phy_driver = {
> .probe = mtk_dp_phy_probe,
> .driver = {
> .name = "mediatek-dp-phy",
> + .of_match_table = mtk_dp_phy_of_match,
> },
> };
[Severity: Medium]
Does this driver need a .remove callback to clean up the PM runtime state?
Since pm_runtime_enable() and pm_runtime_get_sync() are called in probe
without devm_ handlers or registered teardown actions, unbinding the driver
appears to leak the usage counter and leave PM runtime permanently enabled.
> module_platform_driver(mtk_dp_phy_driver);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701122008.19509-1-angelogioacchino.delregno@collabora.com?part=3
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-01 12:30 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 12:19 [PATCH 00/12] PHY: MediaTek DP PHY refactor and MT8196 eDP AngeloGioacchino Del Regno
2026-07-01 12:19 ` AngeloGioacchino Del Regno
2026-07-01 12:19 ` [PATCH 01/12] dt-bindings: phy: Document MT8195 and MT8196 DisplayPort PHYs AngeloGioacchino Del Regno
2026-07-01 12:19 ` AngeloGioacchino Del Regno
2026-07-01 12:27 ` sashiko-bot
2026-07-01 12:27 ` sashiko-bot
2026-07-01 13:07 ` AngeloGioacchino Del Regno
2026-07-01 13:07 ` AngeloGioacchino Del Regno
2026-07-01 14:38 ` Rob Herring (Arm)
2026-07-01 14:38 ` Rob Herring (Arm)
2026-07-01 12:19 ` [PATCH 02/12] phy: phy-mtk-dp: Rename regs to regmap in struct mtk_dp_phy AngeloGioacchino Del Regno
2026-07-01 12:19 ` AngeloGioacchino Del Regno
2026-07-01 12:26 ` sashiko-bot
2026-07-01 12:26 ` sashiko-bot
2026-07-01 13:05 ` AngeloGioacchino Del Regno
2026-07-01 13:05 ` AngeloGioacchino Del Regno
2026-07-01 12:19 ` [PATCH 03/12] phy: phy-mtk-dp: Allow probing with devicetree match AngeloGioacchino Del Regno
2026-07-01 12:19 ` AngeloGioacchino Del Regno
2026-07-01 12:30 ` sashiko-bot [this message]
2026-07-01 12:30 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 04/12] phy: phy-mtk-dp: Migrate register offsets to SoC specific pdata AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:36 ` sashiko-bot
2026-07-01 12:36 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 05/12] phy: phy-mtk-dp: Implement power_on and power_off PHY callbacks AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:39 ` sashiko-bot
2026-07-01 12:39 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 06/12] phy: phy-mtk-dp: Support set_lanes in configure and properly cleanup AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:35 ` sashiko-bot
2026-07-01 12:35 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 07/12] phy: phy-mtk-dp: Support setting volt swing and preemphasis values AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:49 ` sashiko-bot
2026-07-01 12:49 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 08/12] phy: phy-mtk-dp: Add support for digital and analog calibration AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:48 ` sashiko-bot
2026-07-01 12:48 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 09/12] phy: phy-mtk-dp: Rewrite and document default driving param macros AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 12:50 ` sashiko-bot
2026-07-01 12:50 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 10/12] phy: phy-mtk-dp: Add bitrate register val definitions to SoC data AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 13:02 ` sashiko-bot
2026-07-01 13:02 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 11/12] phy: phy-mtk-dp: Add PHYD Lane EN register mask " AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 13:07 ` sashiko-bot
2026-07-01 13:07 ` sashiko-bot
2026-07-01 12:20 ` [PATCH 12/12] phy: phy-mtk-dp: Add support for MT8196 eDP PHY AngeloGioacchino Del Regno
2026-07-01 12:20 ` AngeloGioacchino Del Regno
2026-07-01 13:01 ` sashiko-bot
2026-07-01 13:01 ` 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=20260701123003.B65211F000E9@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=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.