usb: dwc3: pci: Fix reference count leak in dwc3_pci_resume_work
authorAditya Pakki <pakki001@umn.edu>
Sun, 14 Jun 2020 03:15:25 +0000 (22:15 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jul 2020 06:13:16 +0000 (08:13 +0200)
[ Upstream commit 2655971ad4b34e97dd921df16bb0b08db9449df7 ]

dwc3_pci_resume_work() calls pm_runtime_get_sync() that increments
the reference counter. In case of failure, decrement the reference
before returning.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/dwc3/dwc3-pci.c

index b67372737dc9b23e37d00b4970bec7ea15c037d2..96c05b121fac85137eedfc5b9e13cdc1dda12c39 100644 (file)
@@ -206,8 +206,10 @@ static void dwc3_pci_resume_work(struct work_struct *work)
        int ret;
 
        ret = pm_runtime_get_sync(&dwc3->dev);
-       if (ret)
+       if (ret) {
+               pm_runtime_put_sync_autosuspend(&dwc3->dev);
                return;
+       }
 
        pm_runtime_mark_last_busy(&dwc3->dev);
        pm_runtime_put_sync_autosuspend(&dwc3->dev);