From: sashiko-bot@kernel.org
To: Biju <biju.das.au@gmail.com>
Cc: wsa+renesas@sang-engineering.com, neil.armstrong@linaro.org,
vkoul@kernel.org, olteanv@gmail.com,
linux-phy@lists.infradead.org
Subject: Re: [PATCH v5 7/9] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator
Date: Wed, 29 Jul 2026 12:08:48 +0000 [thread overview]
Message-ID: <20260729120849.0D36A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729115022.222340-8-biju.das.jz@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch replaces logical reference tracking with a hardware state check that evaluates negative error codes as true and skips cleanup on mismatch, causing `enable_count` leaks and kernel warnings.
--
--- Patch [7]: [PATCH v5 7/9] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator ---
commit b4d6d24f697dee807a883f959100e138c3feeef3
Author: Biju Das <biju.das.jz@bp.renesas.com>
phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator
This commit modifies the VBUS regulator initialization to always register
the devm disable action if the regulator is currently enabled. It uses
regulator_is_enabled() to determine the hardware state, attempting to
ensure that the initial enabled state from devm_regulator_get_exclusive()
is properly cleaned up.
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index d06fb52ed5f1b..ef38c3b365d42 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -905,15 +905,17 @@ static int rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(struct rcar_ge
[ ... ]
> + if (enable) {
> + ret = regulator_enable(channel->vbus);
> + if (ret)
> + return ret;
> + }
>
> - ret = regulator_enable(channel->vbus);
> - if (ret)
> - return ret;
> + if (regulator_is_enabled(channel->vbus))
> + return devm_add_action_or_reset(dev, rcar_gen3_phy_usb2_vbus_disable_action,
> + channel->vbus);
[Severity: Medium]
Can this cause issues if regulator_is_enabled() returns a negative error
code?
If the underlying communication fails, regulator_is_enabled() will return a
negative value which evaluates as true. This would erroneously register the
devm disable action even when the enable_count is 0, triggering a WARN in
regulator_disable() on driver unbind.
Additionally, if the caller explicitly requested enable, regulator_enable()
will unconditionally increment the enable_count. If the subsequent check
returns 0 due to hardware ramp-up delays before the status register reflects
the state, the cleanup action would be skipped.
Would this leak the reference and trigger a WARN_ON() for the enable_count
in regulator_put() upon device removal?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729115022.222340-1-biju.das.jz@bp.renesas.com?part=7
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
prev parent reply other threads:[~2026-07-29 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 11:50 [PATCH v5 0/9] Add RZ/G3L USB2.0 host support Biju
2026-07-29 11:50 ` [PATCH v5 5/9] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3L PHY bindings Biju
2026-07-29 11:50 ` [PATCH v5 6/9] phy: renesas: phy-rcar-gen3-usb2: Add RZ/G3L support Biju
2026-07-29 11:50 ` [PATCH v5 7/9] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator Biju
2026-07-29 12:08 ` sashiko-bot [this message]
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=20260729120849.0D36A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=biju.das.au@gmail.com \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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