]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
usb: core: hub: Fix PM reference leak in usb_port_resume()
authorBixuan Cui <cuibixuan@huawei.com>
Thu, 8 Apr 2021 13:08:31 +0000 (21:08 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:59:38 +0000 (10:59 +0200)
BugLink: https://bugs.launchpad.net/bugs/1928825
[ Upstream commit 025f97d188006eeee4417bb475a6878d1e0eed3f ]

pm_runtime_get_sync will increment pm usage counter even it failed.
thus a pairing decrement is needed.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
Link: https://lore.kernel.org/r/20210408130831.56239-1-cuibixuan@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/core/hub.c

index f1a8e67a775917d7005a0cbdc5d68e7db76a7ec8..5576bd97b83b95bb2534bfd67d1e0f7dc4a2e755 100644 (file)
@@ -3570,7 +3570,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
        u16             portchange, portstatus;
 
        if (!test_and_set_bit(port1, hub->child_usage_bits)) {
-               status = pm_runtime_get_sync(&port_dev->dev);
+               status = pm_runtime_resume_and_get(&port_dev->dev);
                if (status < 0) {
                        dev_dbg(&udev->dev, "can't resume usb port, status %d\n",
                                        status);