Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: linux-phy@lists.infradead.org, olteanv@gmail.com,
	neil.armstrong@linaro.org, vkoul@kernel.org
Subject: Re: [PATCH v6 5/7] phy: qcom: snps-femto-v2: Fix possible NULL-deref on early runtime suspend
Date: Wed, 22 Jul 2026 13:56:57 +0000	[thread overview]
Message-ID: <20260722135658.619991F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722-qcom-usb-phy-fix-null-v6-5-534f7e61b9a6@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch leaves a window on the devm_phy_create() error path where a concurrent sysfs write could trigger a NULL pointer dereference in the runtime PM suspend callback.
--

--- Patch [5]: [PATCH v6 5/7] phy: qcom: snps-femto-v2: Fix possible NULL-deref on early runtime suspend ---
commit a0879a68c7ebe908247653778b80f7d2758ec42f
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>

phy: qcom: snps-femto-v2: Fix possible NULL-deref on early runtime suspend

This commit holds a runtime PM usage reference during probe to prevent early
runtime suspend callbacks from dereferencing uninitialized PHY data. It also
converts the runtime PM enable call to its devres-managed variant to ensure
proper cleanup on driver removal.

> diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> --- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> +++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
[ ... ]
> @@ -611,6 +621,7 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev)
>  	if (IS_ERR(generic_phy)) {
>  		ret = PTR_ERR(generic_phy);
>  		dev_err(dev, "failed to create phy, %d\n", ret);
> +		pm_runtime_put_noidle(dev);
>  		return ret;
>  	}

[Severity: High]
This is a pre-existing issue, but does dropping the usage reference here
leave the device vulnerable to a NULL pointer dereference?

If devm_phy_create() fails, the driver drops its runtime PM usage count
and returns. Because devm_pm_runtime_enable() is used, runtime PM is not
disabled synchronously, but is deferred to devres cleanup.

In this window, could a concurrent sysfs write to power/control (e.g.,
from udev rules) trigger an asynchronous suspend?

Since devres cleanup calls pm_runtime_disable() which waits for any
in-progress suspend to complete rather than canceling it, and
dev_set_drvdata() is bypassed on this error path, wouldn't the runtime
suspend callback retrieve and dereference a NULL pointer?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-qcom-usb-phy-fix-null-v6-0-534f7e61b9a6@oss.qualcomm.com?part=5

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-07-22 13:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 13:45 [PATCH v6 0/7] phy: qcom: Fix possible NULL-deref and runtime PM race conditions Loic Poulain
2026-07-22 13:45 ` [PATCH v6 1/7] phy: qcom: qmp-combo: Prevent unnecessary PM runtime suspend at boot Loic Poulain
2026-07-22 13:45 ` [PATCH v6 2/7] phy: qcom: qmp-usbc: " Loic Poulain
2026-07-22 13:45 ` [PATCH v6 3/7] phy: qcom: qmp-usb-legacy: Fix possible NULL-deref on early runtime suspend Loic Poulain
2026-07-22 13:45 ` [PATCH v6 4/7] phy: qcom: qmp-usb-legacy: Prevent unnecessary PM runtime suspend at boot Loic Poulain
2026-07-22 13:45 ` [PATCH v6 5/7] phy: qcom: snps-femto-v2: Fix possible NULL-deref on early runtime suspend Loic Poulain
2026-07-22 13:56   ` sashiko-bot [this message]
2026-07-22 13:45 ` [PATCH v6 6/7] phy: qcom: qmp-usb: " Loic Poulain
2026-07-22 13:45 ` [PATCH v6 7/7] phy: qcom: qmp-usb: Prevent unnecessary PM runtime suspend at boot Loic Poulain

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=20260722135658.619991F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox