Commit a5f928db authored by Sergey Shtylyov's avatar Sergey Shtylyov Committed by Greg Kroah-Hartman

usb: host: xhci-plat: fix possible kernel oops while resuming

If this driver enables the xHC clocks while resuming from sleep, it calls
clk_prepare_enable() without checking for errors and blithely goes on to
read/write the xHC's registers -- which, with the xHC not being clocked,
at least on ARM32 usually causes an imprecise external abort exceptions
which cause kernel oops.  Currently, the chips for which the driver does
the clock dance on suspend/resume seem to be the Broadcom STB SoCs, based
on ARM32 CPUs, as it seems...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Fixes: 8bd954c5 ("usb: host: xhci-plat: suspend and resume clocks")
Signed-off-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20231019102924.2797346-19-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6ccb83d6
......@@ -458,23 +458,38 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
int ret;
if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
clk_prepare_enable(xhci->clk);
clk_prepare_enable(xhci->reg_clk);
ret = clk_prepare_enable(xhci->clk);
if (ret)
return ret;
ret = clk_prepare_enable(xhci->reg_clk);
if (ret) {
clk_disable_unprepare(xhci->clk);
return ret;
}
}
ret = xhci_priv_resume_quirk(hcd);
if (ret)
return ret;
goto disable_clks;
ret = xhci_resume(xhci, PMSG_RESUME);
if (ret)
return ret;
goto disable_clks;
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return 0;
disable_clks:
if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
clk_disable_unprepare(xhci->clk);
clk_disable_unprepare(xhci->reg_clk);
}
return ret;
}
static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment