Skip to content

Commit d4d2e53

Browse files
Dan Carpentergregkh
authored andcommitted
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: 8253a34 ("usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle") Cc: stable <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/20211117074923.GF5237@kili Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6ae6dc2 commit d4d2e53

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
420420
data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
421421
if (IS_ERR(data->phy)) {
422422
ret = PTR_ERR(data->phy);
423-
if (ret == -ENODEV) {
424-
data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
425-
if (IS_ERR(data->phy)) {
426-
ret = PTR_ERR(data->phy);
427-
if (ret == -ENODEV)
428-
data->phy = NULL;
429-
else
430-
goto err_clk;
431-
}
423+
if (ret != -ENODEV)
424+
goto err_clk;
425+
data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
426+
if (IS_ERR(data->phy)) {
427+
ret = PTR_ERR(data->phy);
428+
if (ret == -ENODEV)
429+
data->phy = NULL;
430+
else
431+
goto err_clk;
432432
}
433433
}
434434

0 commit comments

Comments
 (0)