usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probe
Subsystems (4)
PATCH 1/1 usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probe
If the first call to devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0) fails with something other than -ENODEV then it leads to an error pointer dereference. For those errors we should just jump directly to the error handling.
Fixes 8253a34bfae3 ("usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/usb/chipidea/ci_hdrc_imx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +9 -9
@@ -420,15 +420,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) data->phy =devm_usb_get_phy_by_phandle (dev,"fsl,usbphy" ,0 );if (IS_ERR (data->phy)) { ret =PTR_ERR (data->phy); -if (ret == -ENODEV ) { - data->phy =devm_usb_get_phy_by_phandle (dev,"phys" ,0 ); -if (IS_ERR (data->phy)) { - ret =PTR_ERR (data->phy); -if (ret == -ENODEV ) - data->phy =NULL ; -else - goto err_clk; - } +if (ret != -ENODEV ) + goto err_clk; + data->phy =devm_usb_get_phy_by_phandle (dev,"phys" ,0 ); +if (IS_ERR (data->phy)) { + ret =PTR_ERR (data->phy); +if (ret == -ENODEV ) + data->phy =NULL ; +else + goto err_clk; } }
Signature · 1 line
2.20.1
Quoted 43 lines · Dan Carpenter
If the first call to
devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0)fails with something other than-ENODEVthen it leads to an error pointer dereference. For those errors we should just jump directly to the error handling.Fixes 8253a34bfae3 ("usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle")Signed-off-by Dan Carpenter <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/usb/chipidea/ci_hdrc_imx.c +9
-9@@ -420,15 +420,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) data->phy =devm_usb_get_phy_by_phandle (dev,"fsl,usbphy" ,0 );if (IS_ERR (data->phy)) { ret =PTR_ERR (data->phy); -if (ret == -ENODEV ) { - data->phy =devm_usb_get_phy_by_phandle (dev,"phys" ,0 ); -if (IS_ERR (data->phy)) { - ret =PTR_ERR (data->phy); -if (ret == -ENODEV ) - data->phy =NULL ; -else - goto err_clk; - } +if (ret != -ENODEV ) + goto err_clk; + data->phy =devm_usb_get_phy_by_phandle (dev,"phys" ,0 ); +if (IS_ERR (data->phy)) { + ret =PTR_ERR (data->phy); +if (ret == -ENODEV ) + data->phy =NULL ; +else + goto err_clk; } }Signature · 1 line
2.20.1
Acked-by Peter Chen <[email protected]>
Signature · 2 lines
Thanks, Peter Chen