All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rustam Adilov" <adilov@disroot.org>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v9 2/6] phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct
Date: Fri, 16 Oct 2026 18:15:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-174758@kernel.org> (raw)
In-Reply-To: <20261016180314.31760-3-adilov@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] phy: missing NULL check for of_iomap() in parse_phy_data()
--

commit a9528213c2ade387d2252d526e2e1e2c2162eeba
Author: Rustam Adilov <adilov@disroot.org>

phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct

RTL9607C is a big endian SoC with little endian USB host controller but
vstatus register is from big endian memory region and thus existing
writel doesn't work. It needs either __raw_writel or iowrite32be
instead.

To handle this situation, introduce read and write function to the
phy_reg_desc struct and add a default variation that is going to be
ponted by the existing rtd_phy_reg_desc.

> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
> index e8d0f0119ec0a..5e483c853f02f 100644
> --- a/drivers/phy/realtek/phy-rtk-usb2.c
> +++ b/drivers/phy/realtek/phy-rtk-usb2.c
[ ... ]
> @@ -204,8 +216,8 @@ static int rtk_phy_write(struct phy_reg *phy_reg, char addr, char data)
>  	int ret = 0;
>  
>  	/* write data to VStatusOut2 (data output to phy) */
> -	writel((u32)data << shift_bits,
> -	       reg_wrap_vstatus + reg_desc->vstatus_offset);
> +	reg_desc->write((u32)data << shift_bits,
> +		       reg_wrap_vstatus + reg_desc->vstatus_offset);

[Severity: High]
Does this code risk dereferencing a NULL pointer if of_iomap() fails?

In parse_phy_data(), the results of of_iomap() are assigned to both
reg_wrap_vstatus and reg_gusb2phyacc0 without being checked for NULL:

parse_phy_data() {
    ...
    phy_parameter->phy_reg.reg_wrap_vstatus = of_iomap(np, 0);
    phy_parameter->phy_reg.reg_gusb2phyacc0 = of_iomap(np, 1) + index;
    ...
}

Later, in rtk_phy_write(), the reg_wrap_vstatus pointer is dereferenced here
when writing to the register. Should we verify that the device tree memory
mappings were successful before they are used?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016180314.31760-1-adilov@disroot.org?part=2

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Rustam Adilov" <adilov@disroot.org>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v9 2/6] phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct
Date: Fri, 16 Oct 2026 18:15:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-174758@kernel.org> (raw)
In-Reply-To: <20261016180314.31760-3-adilov@disroot.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] phy: missing NULL check for of_iomap() in parse_phy_data()
--

commit a9528213c2ade387d2252d526e2e1e2c2162eeba
Author: Rustam Adilov <adilov@disroot.org>

phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct

RTL9607C is a big endian SoC with little endian USB host controller but
vstatus register is from big endian memory region and thus existing
writel doesn't work. It needs either __raw_writel or iowrite32be
instead.

To handle this situation, introduce read and write function to the
phy_reg_desc struct and add a default variation that is going to be
ponted by the existing rtd_phy_reg_desc.

> diff --git a/drivers/phy/realtek/phy-rtk-usb2.c b/drivers/phy/realtek/phy-rtk-usb2.c
> index e8d0f0119ec0a..5e483c853f02f 100644
> --- a/drivers/phy/realtek/phy-rtk-usb2.c
> +++ b/drivers/phy/realtek/phy-rtk-usb2.c
[ ... ]
> @@ -204,8 +216,8 @@ static int rtk_phy_write(struct phy_reg *phy_reg, char addr, char data)
>  	int ret = 0;
>  
>  	/* write data to VStatusOut2 (data output to phy) */
> -	writel((u32)data << shift_bits,
> -	       reg_wrap_vstatus + reg_desc->vstatus_offset);
> +	reg_desc->write((u32)data << shift_bits,
> +		       reg_wrap_vstatus + reg_desc->vstatus_offset);

[Severity: High]
Does this code risk dereferencing a NULL pointer if of_iomap() fails?

In parse_phy_data(), the results of of_iomap() are assigned to both
reg_wrap_vstatus and reg_gusb2phyacc0 without being checked for NULL:

parse_phy_data() {
    ...
    phy_parameter->phy_reg.reg_wrap_vstatus = of_iomap(np, 0);
    phy_parameter->phy_reg.reg_gusb2phyacc0 = of_iomap(np, 1) + index;
    ...
}

Later, in rtk_phy_write(), the reg_wrap_vstatus pointer is dereferenced here
when writing to the register. Should we verify that the device tree memory
mappings were successful before they are used?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016180314.31760-1-adilov@disroot.org?part=2

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

  reply	other threads:[~2026-10-16 18:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 18:03 [PATCH v9 0/6] phy: realtek: usb2: support for RTL9607C USB2 PHY Rustam Adilov
2026-10-16 18:03 ` Rustam Adilov
2026-10-16 18:03 ` [PATCH v9 1/6] phy: realtek: usb2: introduce phy_reg_desc struct to the driver Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov
2026-10-16 18:15   ` sashiko-bot
2026-10-16 18:15     ` sashiko-bot
2026-10-16 18:35     ` Rustam Adilov
2026-10-16 18:35       ` Rustam Adilov
2026-10-16 18:03 ` [PATCH v9 2/6] phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov
2026-10-16 18:15   ` sashiko-bot [this message]
2026-10-16 18:15     ` sashiko-bot
2026-10-16 18:03 ` [PATCH v9 3/6] dt-bindings: phy: realtek,usb2phy: extend for resets and RTL9607C support Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov
2026-10-16 18:03 ` [PATCH v9 4/6] phy: realtek: usb2: introduce reset controller struct Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov
2026-10-16 18:15   ` sashiko-bot
2026-10-16 18:15     ` sashiko-bot
2026-10-16 18:31     ` Rustam Adilov
2026-10-16 18:31       ` Rustam Adilov
2026-10-16 18:03 ` [PATCH v9 5/6] phy: realtek: usb2: add support for RTL9607C USB2 PHY Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov
2026-10-16 18:17   ` sashiko-bot
2026-10-16 18:17     ` sashiko-bot
2026-10-16 18:03 ` [PATCH v9 6/6] phy: realtek: Make configs available for MACH_REALTEK_RTL Rustam Adilov
2026-10-16 18:03   ` Rustam Adilov

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=sashiko-outbox-174758@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adilov@disroot.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=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.