* RE: [PATCH] phy: realtek: usb: fix the USB 2.0 PHY's port range check
[not found] <202611041419.6A4EJBeM41365932@rtits1.realtek.com.tw>
@ 2026-11-05 6:12 ` Stanley Chang[昌育德]
0 siblings, 0 replies; 2+ messages in thread
From: Stanley Chang[昌育德] @ 2026-11-05 6:12 UTC (permalink / raw)
To: Joshua Scott, Vinod Koul, linux-phy
Cc: Neil Armstrong, Manivannan Sadhasivam, Greg Kroah-Hartman,
linux-kernel, stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] phy: realtek: usb: fix the USB 2.0 PHY's port range check
@ 2026-11-03 22:14 Joshua Scott
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Scott @ 2026-11-03 22:14 UTC (permalink / raw)
To: Vinod Koul, linux-phy
Cc: Neil Armstrong, Manivannan Sadhasivam, Stanley Chang,
Greg Kroah-Hartman, linux-kernel, Joshua Scott, stable
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;
base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 6:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <202611041419.6A4EJBeM41365932@rtits1.realtek.com.tw>
2026-11-05 6:12 ` [PATCH] phy: realtek: usb: fix the USB 2.0 PHY's port range check Stanley Chang[昌育德]
2026-11-03 22:14 Joshua Scott
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®