]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PM: runtime: Fix ordering in pm_runtime_get_suppliers()
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 26 Mar 2021 10:56:18 +0000 (12:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Apr 2021 10:48:49 +0000 (12:48 +0200)
commit c0c33442f7203704aef345647e14c2fb86071001 upstream.

rpm_active indicates how many times the supplier usage_count has been
incremented. Consequently it must be updated after pm_runtime_get_sync() of
the supplier, not before.

Fixes: 4c06c4e6cf63 ("driver core: Fix possible supplier PM-usage counter imbalance")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: 5.1+ <stable@vger.kernel.org> # 5.1+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/runtime.c

index f1cac08fa8bb5a65d335b154a7472faa1a05c28c..eaae4adf9ce4bc5a3c8b3ff12e2c99e86340e7f1 100644 (file)
@@ -1572,8 +1572,8 @@ void pm_runtime_get_suppliers(struct device *dev)
        list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
                if (link->flags & DL_FLAG_PM_RUNTIME) {
                        link->supplier_preactivated = true;
-                       refcount_inc(&link->rpm_active);
                        pm_runtime_get_sync(link->supplier);
+                       refcount_inc(&link->rpm_active);
                }
 
        device_links_read_unlock(idx);