All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, conor+dt@kernel.org,
	olteanv@gmail.com, robh@kernel.org,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v8 07/29] phy: rockchip: usbdp: Handle rk_udphy_reset_deassert_all errors in init check
Date: Fri, 26 Jun 2026 21:11:50 +0000	[thread overview]
Message-ID: <20260626211151.2332F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626-rockchip-usbdp-cleanup-v8-7-47f682987895@collabora.com>

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

Pre-existing issues:
- [Medium] The return value of `regmap_read` is ignored, leading to the use of an uninitialized stack variable.
- [Medium] The patch fails to address identical reset deassertion vulnerabilities in `rk_udphy_init`, leaving the driver susceptible to the exact same SError it claims to fix.
--

commit af7a83cb1b1746054cd095d5743210c65397d6b1
Author: Sebastian Reichel <sebastian.reichel@collabora.com>

phy: rockchip: usbdp: Handle rk_udphy_reset_deassert_all errors in init check

This commit fixes a theoretical SError issue by ensuring that the return
value of rk_udphy_reset_deassert_all is checked. It bails out early if
deasserting the reset lines fails before attempting further register access.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/message/20260619154903.2225A1F000E9%40smtp.kernel.org

> Fix theoretical issue, that failure to deassert the reset lines would
> result in an SError in follow-up register access. Note, that this cannot
> happen with current code, since the Rockchip reset driver never returns
> any errors for (de)asserting reset lines.

[Severity: Medium]
This is a pre-existing issue, but does this same vulnerability still exist in
rk_udphy_init() where reset deassertions are also unchecked?

For example:

drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_init() {
	...
	rk_udphy_reset_deassert(udphy, "pma_apb");
	rk_udphy_reset_deassert(udphy, "pcs_apb");

	/* Step 2: set init sequence and phy refclk */
	ret = regmap_multi_reg_write(udphy->pma_regmap, ...
	...
}

If rk_udphy_reset_deassert() fails here, wouldn't the follow-up
regmap_multi_reg_write() trigger the exact same SError?

Should the reset deassertions in rk_udphy_init() also be checked?

> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index f7ff55f03b7cf..b8de0a47a6165 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -936,7 +936,9 @@ static int rk_udphy_get_initial_status(struct rk_udphy *udphy)
>  		return ret;
>  	}
>  
> -	rk_udphy_reset_deassert_all(udphy);
> +	ret = rk_udphy_reset_deassert_all(udphy);
> +	if (ret)
> +		goto exit;
>  
>  	regmap_read(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, &value);
>  	if (FIELD_GET(CMN_DP_LANE_MUX_ALL, value) && FIELD_GET(CMN_DP_LANE_EN_ALL, value)) {

[Severity: Medium]
This is a pre-existing issue, but does this code evaluate an uninitialized
variable if the read fails?

If regmap_read() fails and returns an error, value is not initialized, and
the subsequent FIELD_GET() checks will operate on uninitialized stack memory.

Should the return value of regmap_read() be checked here?

>  		dev_info(udphy->dev, "Started with DP PHY pre-enabled; seamless takeover unsupported\n");
>  		rk_udphy_grfreg_write(udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, false);
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626-rockchip-usbdp-cleanup-v8-0-47f682987895@collabora.com?part=7

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, conor+dt@kernel.org,
	olteanv@gmail.com, robh@kernel.org,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v8 07/29] phy: rockchip: usbdp: Handle rk_udphy_reset_deassert_all errors in init check
Date: Fri, 26 Jun 2026 21:11:50 +0000	[thread overview]
Message-ID: <20260626211151.2332F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626-rockchip-usbdp-cleanup-v8-7-47f682987895@collabora.com>

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

Pre-existing issues:
- [Medium] The return value of `regmap_read` is ignored, leading to the use of an uninitialized stack variable.
- [Medium] The patch fails to address identical reset deassertion vulnerabilities in `rk_udphy_init`, leaving the driver susceptible to the exact same SError it claims to fix.
--

commit af7a83cb1b1746054cd095d5743210c65397d6b1
Author: Sebastian Reichel <sebastian.reichel@collabora.com>

phy: rockchip: usbdp: Handle rk_udphy_reset_deassert_all errors in init check

This commit fixes a theoretical SError issue by ensuring that the return
value of rk_udphy_reset_deassert_all is checked. It bails out early if
deasserting the reset lines fails before attempting further register access.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/message/20260619154903.2225A1F000E9%40smtp.kernel.org

> Fix theoretical issue, that failure to deassert the reset lines would
> result in an SError in follow-up register access. Note, that this cannot
> happen with current code, since the Rockchip reset driver never returns
> any errors for (de)asserting reset lines.

[Severity: Medium]
This is a pre-existing issue, but does this same vulnerability still exist in
rk_udphy_init() where reset deassertions are also unchecked?

For example:

drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_init() {
	...
	rk_udphy_reset_deassert(udphy, "pma_apb");
	rk_udphy_reset_deassert(udphy, "pcs_apb");

	/* Step 2: set init sequence and phy refclk */
	ret = regmap_multi_reg_write(udphy->pma_regmap, ...
	...
}

If rk_udphy_reset_deassert() fails here, wouldn't the follow-up
regmap_multi_reg_write() trigger the exact same SError?

Should the reset deassertions in rk_udphy_init() also be checked?

> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index f7ff55f03b7cf..b8de0a47a6165 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -936,7 +936,9 @@ static int rk_udphy_get_initial_status(struct rk_udphy *udphy)
>  		return ret;
>  	}
>  
> -	rk_udphy_reset_deassert_all(udphy);
> +	ret = rk_udphy_reset_deassert_all(udphy);
> +	if (ret)
> +		goto exit;
>  
>  	regmap_read(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, &value);
>  	if (FIELD_GET(CMN_DP_LANE_MUX_ALL, value) && FIELD_GET(CMN_DP_LANE_EN_ALL, value)) {

[Severity: Medium]
This is a pre-existing issue, but does this code evaluate an uninitialized
variable if the read fails?

If regmap_read() fails and returns an error, value is not initialized, and
the subsequent FIELD_GET() checks will operate on uninitialized stack memory.

Should the return value of regmap_read() be checked here?

>  		dev_info(udphy->dev, "Started with DP PHY pre-enabled; seamless takeover unsupported\n");
>  		rk_udphy_grfreg_write(udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, false);
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626-rockchip-usbdp-cleanup-v8-0-47f682987895@collabora.com?part=7

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

  reply	other threads:[~2026-06-26 21:11 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 20:54 [PATCH v8 00/29] phy: rockchip: usbdp: Fixes, DP 1-lane support and cleanups Sebastian Reichel
2026-06-26 20:54 ` Sebastian Reichel
2026-06-26 20:54 ` Sebastian Reichel
2026-06-26 20:54 ` [PATCH v8 01/29] dt-bindings: phy: rockchip-usbdp: add improved ports scheme Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 21:13   ` sashiko-bot
2026-06-26 21:13     ` sashiko-bot
2026-06-26 20:54 ` [PATCH v8 02/29] phy: rockchip: usbdp: Update mode_change after error handling Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54 ` [PATCH v8 03/29] phy: rockchip: usbdp: Do not lose USB3 PHY status Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 21:16   ` sashiko-bot
2026-06-26 21:16     ` sashiko-bot
2026-06-26 20:54 ` [PATCH v8 04/29] phy: rockchip: usbdp: Fix devm_clk_bulk_get_all check Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54 ` [PATCH v8 05/29] phy: rockchip: usbdp: Handle missing clock-names DT property gracefully Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 21:12   ` sashiko-bot
2026-06-26 21:12     ` sashiko-bot
2026-06-26 20:54 ` [PATCH v8 06/29] phy: rockchip: usbdp: Drop seamless DP takeover Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 20:54   ` Sebastian Reichel
2026-06-26 21:16   ` sashiko-bot
2026-06-26 21:16     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 07/29] phy: rockchip: usbdp: Handle rk_udphy_reset_deassert_all errors in init check Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:11   ` sashiko-bot [this message]
2026-06-26 21:11     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 08/29] phy: rockchip: usbdp: Keep clocks running on PHY re-init Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 09/29] phy: rockchip: usbdp: Amend SSC modulation deviation Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 10/29] phy: rockchip: usbdp: Fix LFPS detect threshold control Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 11/29] phy: rockchip: usbdp: Add missing mode_change update Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 12/29] phy: rockchip: usbdp: Support single-lane DP Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:19   ` sashiko-bot
2026-06-26 21:19     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 13/29] phy: rockchip: usbdp: Limit DP lane count to muxed lanes Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:17   ` sashiko-bot
2026-06-26 21:17     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 14/29] phy: rockchip: usbdp: Rename DP lane functions Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 15/29] phy: rockchip: usbdp: Use FIELD_PREP_WM16_CONST Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 16/29] phy: rockchip: usbdp: Cleanup DP lane selection function Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 17/29] phy: rockchip: usbdp: Register DP aux bridge Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:14   ` sashiko-bot
2026-06-26 21:14     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 18/29] phy: rockchip: usbdp: Drop DP HPD handling Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 19/29] phy: rockchip: usbdp: Rename mode_change to phy_needs_reinit Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 20/29] phy: rockchip: usbdp: Re-init the PHY on orientation change Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:18   ` sashiko-bot
2026-06-26 21:18     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 21/29] phy: rockchip: usbdp: Factor out lane_mux_sel setup Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 22/29] phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 23/29] phy: rockchip: usbdp: Use guard functions for mutex Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 24/29] phy: rockchip: usbdp: Support going from DP-only mode to USB mode Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:17   ` sashiko-bot
2026-06-26 21:17     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 25/29] phy: rockchip: usbdp: Clear USB status on PHY exit Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:17   ` sashiko-bot
2026-06-26 21:17     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 26/29] phy: rockchip: usbdp: Hold mutex in DP PHY configure Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 27/29] phy: rockchip: usbdp: Add some extra debug messages Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55 ` [PATCH v8 28/29] phy: rockchip: usbdp: Avoid xHCI SErrors Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:24   ` sashiko-bot
2026-06-26 21:24     ` sashiko-bot
2026-06-26 20:55 ` [PATCH v8 29/29] phy: rockchip: usbdp: Disable USB3 on probe Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 20:55   ` Sebastian Reichel
2026-06-26 21:24   ` sashiko-bot
2026-06-26 21:24     ` 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=20260626211151.2332F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.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=sebastian.reichel@collabora.com \
    --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.