]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
USB: dwc3: fix runtime pm imbalance on probe errors
authorJohan Hovold <johan+linaro@kernel.org>
Tue, 4 Apr 2023 07:25:14 +0000 (09:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:10:49 +0000 (23:10 +0900)
commit 9a8ad10c9f2e0925ff26308ec6756b93fc2f4977 upstream.

Make sure not to suspend the device when probe fails to avoid disabling
clocks and phys multiple times.

Fixes: 328082376aea ("usb: dwc3: fix runtime PM in error path")
Cc: stable@vger.kernel.org # 4.8
Cc: Roger Quadros <rogerq@ti.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20230404072524.19014-2-johan+linaro@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.c

index 476b63618511665dc297e8b1ee6272356c9260ad..5058bd8d56cacb9e5eaf063811547cfd7e90c253 100644 (file)
@@ -1883,13 +1883,11 @@ static int dwc3_probe(struct platform_device *pdev)
        spin_lock_init(&dwc->lock);
        mutex_init(&dwc->mutex);
 
+       pm_runtime_get_noresume(dev);
        pm_runtime_set_active(dev);
        pm_runtime_use_autosuspend(dev);
        pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
        pm_runtime_enable(dev);
-       ret = pm_runtime_get_sync(dev);
-       if (ret < 0)
-               goto err1;
 
        pm_runtime_forbid(dev);
 
@@ -1954,12 +1952,10 @@ err3:
        dwc3_free_event_buffers(dwc);
 
 err2:
-       pm_runtime_allow(&pdev->dev);
-
-err1:
-       pm_runtime_put_sync(&pdev->dev);
-       pm_runtime_disable(&pdev->dev);
-
+       pm_runtime_allow(dev);
+       pm_runtime_disable(dev);
+       pm_runtime_set_suspended(dev);
+       pm_runtime_put_noidle(dev);
 disable_clks:
        dwc3_clk_disable(dwc);
 assert_reset: