]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ACPI: PM: Fix device wakeup power reference counting error
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 4 Nov 2021 21:54:17 +0000 (22:54 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:48:36 +0000 (09:48 +0100)
BugLink: https://bugs.launchpad.net/bugs/1951822
[ Upstream commit 452a3e723f75880757acf87b053935c43aa89f89 ]

Fix a device wakeup power reference counting error introduced by
commit a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power
resources") because of a coding mistake.

Fixes: a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power resources")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/acpi/power.c

index 4b42debeed455ac79b92a0b147cb386a348ad365..c95eedd58f5bfa77466e06aaee5d8526cb9a64a6 100644 (file)
@@ -755,13 +755,11 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
 
        mutex_lock(&acpi_device_lock);
 
-       if (dev->wakeup.prepare_count > 1) {
-               dev->wakeup.prepare_count--;
+       /* Do nothing if wakeup power has not been enabled for this device. */
+       if (dev->wakeup.prepare_count <= 0)
                goto out;
-       }
 
-       /* Do nothing if wakeup power has not been enabled for this device. */
-       if (!dev->wakeup.prepare_count)
+       if (--dev->wakeup.prepare_count > 0)
                goto out;
 
        err = acpi_device_sleep_wake(dev, 0, 0, 0);