]> git.baikalelectronics.ru Git - kernel.git/commitdiff
phy: stm32: fix an error code in probe
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 14 Oct 2022 09:25:06 +0000 (12:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:42:03 +0000 (17:42 +0100)
[ Upstream commit 0093973eec7cab60103f121a896c251692543a9c ]

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

Fixes: 833c26d115b1 ("phy: stm32: add support for STM32 USB PHY Controller (USBPHYC)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/Y0kq8j6S+5nDdMpr@kili
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/st/phy-stm32-usbphyc.c

index 56bdea4b0bd90cd2d40b5e409bf4d4a0a6e767cf..e643c21c12173ee9a35cdbe6a7cab3fde5f1ab45 100644 (file)
@@ -393,6 +393,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;
                }