Skip to contentSkip to conversation

phy: stm32: fix an error code in probe

PATCH Applied Dan Carpenter 3 participants 3 messages Oct 14, 2022 – Oct 17, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: stm32: fix an error code in probe

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)")
---
 drivers/phy/st/phy-stm32-usbphyc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/phy/st/phy-stm32-usbphyc.c +2 -0
index a98c911cc37a..5bb9647b078f 100644
@@ -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;
 		}
 
Signature · 7 lines
2.35.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

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)")

Thanks Dan,

Quoted 17 lines
---
  drivers/phy/st/phy-stm32-usbphyc.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/phy/st/phy-stm32-usbphyc.c +2 -0
index a98c911cc37a..5bb9647b078f 100644
@@ -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;
  		}
 
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 2 lines · Dan Carpenter

If "index > usbphyc->nphys" is true then this returns success but it should return -EINVAL.

Applied, thanks

Signature · 6 lines
~Vinod

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