PM / Domains: Fix unsafe iteration over modified list of domain providers
authorKrzysztof Kozlowski <krzk@kernel.org>
Wed, 28 Jun 2017 14:56:19 +0000 (16:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2017 22:03:25 +0000 (15:03 -0700)
commit b556b15dc04e9b9b98790f04c21acf5e24f994b2 upstream.

of_genpd_del_provider() iterates over list of domain provides and
removes matching element thus it has to use safe version of list
iteration.

Fixes: aa42240ab254 (PM / Domains: Add generic OF-based PM domain look-up)
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/domain.c

index aff783a108b3896d84f7bc6353b5aee4f033d6cd..ad7e3fb0ea3e966c99480457dc7da99babd7d0c2 100644 (file)
@@ -2056,10 +2056,10 @@ EXPORT_SYMBOL_GPL(__of_genpd_add_provider);
  */
 void of_genpd_del_provider(struct device_node *np)
 {
-       struct of_genpd_provider *cp;
+       struct of_genpd_provider *cp, *tmp;
 
        mutex_lock(&of_genpd_mutex);
-       list_for_each_entry(cp, &of_genpd_providers, link) {
+       list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) {
                if (cp->node == np) {
                        list_del(&cp->link);
                        of_node_put(cp->node);