From: sashiko-bot@kernel.org
To: "Radhey Shyam Pandey" <radhey.shyam.pandey@amd.com>
Cc: olteanv@gmail.com, vkoul@kernel.org, neil.armstrong@linaro.org,
linux-phy@lists.infradead.org
Subject: Re: [PATCH 2/2] phy: zynqmp: fix runtime PM leak on probe allocation failure
Date: Mon, 20 Jul 2026 15:57:32 +0000 [thread overview]
Message-ID: <20260720155732.9DA581F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720153832.1130006-3-radhey.shyam.pandey@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Premature registration of the PHY provider exposes consumers to a Use-After-Free (UAF) if a subsequent probe initialization step fails.
--
--- Patch [2]: [PATCH 2/2] phy: zynqmp: fix runtime PM leak on probe allocation failure ---
commit e07d2a03d56ecad62f1f38421ad1054872a5ffb6
Author: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
phy: zynqmp: fix runtime PM leak on probe allocation failure
This commit moves the devm_kmalloc() allocation for saved_regs before calling
pm_runtime_resume_and_get(). This ensures that an allocation failure does not
leave an unreleased runtime PM usage counter.
> diff --git a/drivers/phy/xilinx/phy-zynqmp.c b/drivers/phy/xilinx/phy-zynqmp.c
> index c8230f2bda629..2138f5399821a 100644
> --- a/drivers/phy/xilinx/phy-zynqmp.c
> +++ b/drivers/phy/xilinx/phy-zynqmp.c
> @@ -1044,6 +1044,12 @@ static int xpsgtr_probe(struct platform_device *pdev)
> return PTR_ERR(provider);
> }
>
> + gtr_dev->saved_regs = devm_kmalloc(gtr_dev->dev,
> + sizeof(save_reg_address),
> + GFP_KERNEL);
> + if (!gtr_dev->saved_regs)
> + return -ENOMEM;
> +
[Severity: High]
This is a pre-existing issue, but does failing the probe here expose a
use-after-free race condition?
Just above this block in xpsgtr_probe(), the driver registers the PHY provider
using devm_of_phy_provider_register(). If this new devm_kmalloc() call (or the
subsequent pm_runtime_resume_and_get() call) fails, the probe function will
return an error. Devres will then automatically free the driver data, including
gtr_dev.
If a consumer device is probing concurrently and obtains a reference to the PHY
before this error path executes, could that consumer later attempt to use the
freed gtr_dev memory when calling phy_init()? Would it be safer to move the
devm_of_phy_provider_register() call to the very end of xpsgtr_probe() after
all initialization and allocations have succeeded?
> pm_runtime_set_active(gtr_dev->dev);
> pm_runtime_enable(gtr_dev->dev);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720153832.1130006-1-radhey.shyam.pandey@amd.com?part=2
--
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-20 15:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 15:38 [PATCH 0/2] phy: zynqmp: fix clock and runtime PM error paths in xpsgtr driver Radhey Shyam Pandey
2026-07-20 15:38 ` Radhey Shyam Pandey
2026-07-20 15:38 ` [PATCH 1/2] phy: zynqmp: fix clock error handling in xpsgtr_phy_init() Radhey Shyam Pandey
2026-07-20 15:38 ` Radhey Shyam Pandey
2026-07-21 5:39 ` Michal Simek
2026-07-21 5:39 ` Michal Simek
2026-07-20 15:38 ` [PATCH 2/2] phy: zynqmp: fix runtime PM leak on probe allocation failure Radhey Shyam Pandey
2026-07-20 15:38 ` Radhey Shyam Pandey
2026-07-20 15:57 ` sashiko-bot [this message]
2026-07-21 5:39 ` Michal Simek
2026-07-21 5:39 ` Michal Simek
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=20260720155732.9DA581F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=radhey.shyam.pandey@amd.com \
--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.