diff mbox series

phy: stm32: fix an error code in probe

Message ID Y0kq8j6S+5nDdMpr@kili
State Accepted
Commit ca1c73628f5bd0c1ef6e46073cc3be2450605b06
Headers show
Series phy: stm32: fix an error code in probe | expand

Commit Message

Dan Carpenter Oct. 14, 2022, 9:25 a.m. UTC
If "index > usbphyc->nphys" is true then this returns success but it
should return -EINVAL.

Fixes: 94c358da3a05 ("phy: stm32: add support for STM32 USB PHY Controller (USBPHYC)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/phy/st/phy-stm32-usbphyc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Amelie Delaunay Oct. 14, 2022, 11:05 a.m. UTC | #1
On 10/14/22 11:25, Dan Carpenter wrote:
> If "index > usbphyc->nphys" is true then this returns success but it
> should return -EINVAL.
> 
> Fixes: 94c358da3a05 ("phy: stm32: add support for STM32 USB PHY Controller (USBPHYC)")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks Dan,

Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>

> ---
>   drivers/phy/st/phy-stm32-usbphyc.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c
> index a98c911cc37a..5bb9647b078f 100644
> --- a/drivers/phy/st/phy-stm32-usbphyc.c
> +++ b/drivers/phy/st/phy-stm32-usbphyc.c
> @@ -710,6 +710,8 @@ static int stm32_usbphyc_probe(struct platform_device *pdev)
>   		ret = of_property_read_u32(child, "reg", &index);
>   		if (ret || index > usbphyc->nphys) {
>   			dev_err(&phy->dev, "invalid reg property: %d\n", ret);
> +			if (!ret)
> +				ret = -EINVAL;
>   			goto put_child;
>   		}
>
Vinod Koul Oct. 17, 2022, 5:25 a.m. UTC | #2
On 14-10-22, 12:25, Dan Carpenter wrote:
> If "index > usbphyc->nphys" is true then this returns success but it
> should return -EINVAL.

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/phy/st/phy-stm32-usbphyc.c b/drivers/phy/st/phy-stm32-usbphyc.c
index a98c911cc37a..5bb9647b078f 100644
--- a/drivers/phy/st/phy-stm32-usbphyc.c
+++ b/drivers/phy/st/phy-stm32-usbphyc.c
@@ -710,6 +710,8 @@  static int stm32_usbphyc_probe(struct platform_device *pdev)
 		ret = of_property_read_u32(child, "reg", &index);
 		if (ret || index > usbphyc->nphys) {
 			dev_err(&phy->dev, "invalid reg property: %d\n", ret);
+			if (!ret)
+				ret = -EINVAL;
 			goto put_child;
 		}