mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Stanley Chang[昌育德]" <stanley_chang@realtek.com>
To: Joshua Scott <joshua.scott@alliedtelesis.co.nz>,
	Vinod Koul <vkoul@kernel.org>,
	"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] phy: realtek: usb: fix the USB 2.0 PHY's port range check
Date: Thu, 5 Nov 2026 06:12:43 +0000	[thread overview]
Message-ID: <0cd63684f1ab4704848f317a96a4105b@realtek.com> (raw)
In-Reply-To: <202611041419.6A4EJBeM41365932@rtits1.realtek.com.tw>

Hi Joshua,


> 
> rtk_phy_toggle() checks the port number before using it to index the
> phy_parameter array, which has num_phy entries. Ports are numbered from
> zero, so the check should reject port == num_phy, but it only rejects ports
> greater than num_phy. Fix the off-by-one.
> 
> Found by code inspection.
> 
> Fixes: eeda494542e5 ("phy: realtek: usb: add new driver for the Realtek RTD
> SoC USB 2.0 PHY")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
> ---
> Prepared with the help of Claude Code (claude-opus-5-5), which drafted the
> change and changelog. I reviewed it and tested it on an RTL9311B board,
> where USB devices still connect and disconnect normally.
> 
>  drivers/phy/realtek/phy-rtk-usb2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c
> b/drivers/phy/realtek/phy-rtk-usb2.c
> index 1f08b151d90a..e43ad5fa6d64 100644
> --- a/drivers/phy/realtek/phy-rtk-usb2.c
> +++ b/drivers/phy/realtek/phy-rtk-usb2.c
> @@ -670,7 +670,7 @@ static void rtk_phy_toggle(struct rtk_phy *rtk_phy,
> bool connect, int port)  {
>         int index = port;
> 
> -       if (index > rtk_phy->num_phy) {
> +       if (index >= rtk_phy->num_phy) {
>                 dev_err(rtk_phy->dev, "%s: The port=%d is not in usb phy
> (num_phy=%d)\n",
>                         __func__, index, rtk_phy->num_phy);
>                 return;

Reviewed-by: Stanley Chang <stanley_chang@realtek.com>


Thanks,
Stanley

       reply	other threads:[~2026-11-05  6:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <202611041419.6A4EJBeM41365932@rtits1.realtek.com.tw>
2026-11-05  6:12 ` Stanley Chang[昌育德] [this message]
2026-11-03 22:14 Joshua Scott

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=0cd63684f1ab4704848f317a96a4105b@realtek.com \
    --to=stanley_chang@realtek.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joshua.scott@alliedtelesis.co.nz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=mani@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=stable@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®