RE: [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg

Biju Das <[email protected]> Mon, 3 Aug 2026 13:26:07 +0000
Newsgroups org.infradead.lists.linux-phy,org.kernel.vger.linux-kernel,org.kernel.vger.linux-renesas-soc
Message-ID <TY3PR01MB11346B7C0EECC1BFBDCAE069386D52@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Hi Felix Gu,

Thanks for the patch.

> -----Original Message-----
> From: Felix Gu <[email protected]>
> Sent: 03 August 2026 14:07
> Subject: [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
> 
> When of_property_read_u32() succeeds but channel_num exceeds
> data->num_channels, rcar_gen2_phy_probe() returns error which is 0,
> so probe reports success even though no PHY provider is registered.
> 
> Return -EINVAL in that case.
> 
> Fixes: 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
> Signed-off-by: Felix Gu <[email protected]>
> ---
>  drivers/phy/renesas/phy-rcar-gen2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
> index 6c671254c625..f0858d8cc705 100644
> --- a/drivers/phy/renesas/phy-rcar-gen2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen2.c
> @@ -390,7 +390,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
>  		error = of_property_read_u32(np, "reg", &channel_num);
>  		if (error || channel_num >= data->num_channels) {
>  			dev_err(dev, "Invalid \"reg\" property\n");
> -			return error;
> +			return error ?: -EINVAL;

Can we use dev_error_probe() here as well??

Cheers,
Biju

>  		}
>  		channel->select_mask = select_mask[channel_num];
> 
> 
> ---
> base-commit: 415606a7be939835db9b0d6b711887586646346d
> change-id: 20260803-rcar-gen2-1-98f440b28b35
> 
> Best regards,
> --
> Felix Gu <[email protected]>

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy