[PATCH v9 2/6] phy: realtek: usb2: introduce read and write functions to phy_reg_desc struct

sashiko-bot at kernel.org sashiko-bot at kernel.org
Fri Oct 16 11:15:26 PDT 2026


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 at 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



More information about the linux-phy mailing list