Devicetree
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: sashiko-reviews@lists.linux.dev
Cc: neil.armstrong@linaro.org, robh@kernel.org,
	devicetree@vger.kernel.org, vkoul@kernel.org, olteanv@gmail.com,
	conor+dt@kernel.org, media-ci@linuxtv.org,
	linux-phy@lists.infradead.org
Subject: Re: [PATCH v13 2/5] phy: core: Add devm_phy_get_by_of_node()
Date: Tue, 28 Jul 2026 11:21:50 +0100	[thread overview]
Message-ID: <4dcc3b8c-8702-4d23-91f2-e3f84567dee4@linaro.org> (raw)
In-Reply-To: <20260728094717.DD9A61F000E9@smtp.kernel.org>

On 28/07/2026 10:47, sashiko-bot@kernel.org wrote:
>> +struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
>> +{
>> +	struct phy **ptr, *phy;
>> +	struct device_link *link;
>> +
>> +	ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
>> +	if (!ptr)
>> +		return ERR_PTR(-ENOMEM);
>> +
>> +	phy = phy_get_by_of_node(np);
> [Severity: High]
> This is a pre-existing issue, but does a TOCTOU race condition exist in the
> underlying phy_get_by_of_node() that could lead to a use-after-free here?
> 
> Looking at phy_get_by_of_node(), it calls _of_phy_get_with_args() to look up
> the PHY. Inside _of_phy_get_with_args(), the function temporarily elevates the
> provider's module refcount, calls of_xlate() (which returns a bare phy
> pointer without incrementing the device refcount), and then drops the module
> refcount and unlocks phy_provider_mutex before returning the raw phy pointer.

This is an interesting idea.

Sounds not implausible and I haven't taken the mutex given in this file 
which is used for adding.

Yes taking the phy_provider mutex seems warranted until the get_device() 
completes.

Actually this is a result of functional decomposition so, I think I 
should add a patch prior here to take the mutex and hold until the 
get_device() in the existing code, then decompose that.

thx

---
bod

  reply	other threads:[~2026-07-28 10:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  9:35 [PATCH v13 0/5] Add dt-bindings and PHY updates for CAMSS on x1e80100 silicon Bryan O'Donoghue
2026-07-28  9:35 ` [PATCH v13 1/5] phy: core: Add phy_get_by_of_node() Bryan O'Donoghue
2026-07-28  9:46   ` sashiko-bot
2026-07-28 10:01     ` Bryan O'Donoghue
2026-07-28  9:35 ` [PATCH v13 2/5] phy: core: Add devm_phy_get_by_of_node() Bryan O'Donoghue
2026-07-28  9:47   ` sashiko-bot
2026-07-28 10:21     ` Bryan O'Donoghue [this message]
2026-07-28 10:46   ` Dmitry Baryshkov
2026-07-28 10:51     ` Bryan O'Donoghue
2026-07-28  9:35 ` [PATCH v13 3/5] media: qcom: camss: Add support for PHY API devices Bryan O'Donoghue
2026-07-28  9:51   ` sashiko-bot
2026-07-28 10:48   ` Dmitry Baryshkov
2026-07-28 11:02   ` Loic Poulain
2026-07-28  9:35 ` [PATCH v13 4/5] dt-bindings: media: qcom,x1e80100-camss: Describe iommu entries Bryan O'Donoghue
2026-07-28 14:44   ` Rob Herring
2026-07-28  9:35 ` [PATCH v13 5/5] dt-bindings: media: qcom,x1e80100-camss: Make vdd-csiphy supplies optional Bryan O'Donoghue
2026-07-28  9:42   ` sashiko-bot
2026-07-28 10:06     ` Bryan O'Donoghue

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=4dcc3b8c-8702-4d23-91f2-e3f84567dee4@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=media-ci@linuxtv.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox