usb: host: ehci-tegra: Fix oops in error cleanup
The cleanup path checks whether the transceiver was properly initialized using IS_ERR(). However it can also happen that the cleanup path is run before the transceiver was initialized (or the operating mode isn't set to TEGRA_USB_OTG) and is therefore NULL. Add a separate label for error unwinding and initialize the transceiver field to ERR_PTR(-ENODEV) when the operating mode isn't TEGRA_USB_OTG to allow for consistent checking. Signed-off-by: Thierry Reding <thierry@gilfi.de> Acked-by: Stephen Warren <swarren@nvidia.com> Acked-by: Venu Byravarasu <vbyravarasu@nvidia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
eb5369edca
commit
369a9a9d2a
|
@ -760,7 +760,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
|
||||||
err = usb_phy_set_suspend(hcd->phy, 0);
|
err = usb_phy_set_suspend(hcd->phy, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "Failed to power on the phy\n");
|
dev_err(&pdev->dev, "Failed to power on the phy\n");
|
||||||
goto fail;
|
goto fail_phy;
|
||||||
}
|
}
|
||||||
|
|
||||||
tegra->host_resumed = 1;
|
tegra->host_resumed = 1;
|
||||||
|
@ -770,7 +770,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
|
||||||
if (!irq) {
|
if (!irq) {
|
||||||
dev_err(&pdev->dev, "Failed to get IRQ\n");
|
dev_err(&pdev->dev, "Failed to get IRQ\n");
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
goto fail;
|
goto fail_phy;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USB_OTG_UTILS
|
#ifdef CONFIG_USB_OTG_UTILS
|
||||||
|
@ -779,6 +779,8 @@ static int tegra_ehci_probe(struct platform_device *pdev)
|
||||||
devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
|
devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
|
||||||
if (!IS_ERR_OR_NULL(tegra->transceiver))
|
if (!IS_ERR_OR_NULL(tegra->transceiver))
|
||||||
otg_set_host(tegra->transceiver->otg, &hcd->self);
|
otg_set_host(tegra->transceiver->otg, &hcd->self);
|
||||||
|
} else {
|
||||||
|
tegra->transceiver = ERR_PTR(-ENODEV);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -803,6 +805,7 @@ fail:
|
||||||
if (!IS_ERR_OR_NULL(tegra->transceiver))
|
if (!IS_ERR_OR_NULL(tegra->transceiver))
|
||||||
otg_set_host(tegra->transceiver->otg, NULL);
|
otg_set_host(tegra->transceiver->otg, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
fail_phy:
|
||||||
usb_phy_shutdown(hcd->phy);
|
usb_phy_shutdown(hcd->phy);
|
||||||
fail_io:
|
fail_io:
|
||||||
clk_disable_unprepare(tegra->clk);
|
clk_disable_unprepare(tegra->clk);
|
||||||
|
|
Loading…
Reference in New Issue