PM / Domains: Handle safely genpd_syscore_switch() call on non-genpd device
authorKrzysztof Kozlowski <krzk@kernel.org>
Wed, 28 Jun 2017 14:56:17 +0000 (16:56 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 28 Jun 2017 23:24:35 +0000 (01:24 +0200)
commit8b55e55ee44356d68f4a7ee4b11f9cbb1f5958cc
treea64beb938e255e47a048857c8b08329a63bd2783
parent10da65423fdbee185da5bb65f829a9d9312c1198
PM / Domains: Handle safely genpd_syscore_switch() call on non-genpd device

genpd_syscore_switch() had two problems:
 1. It silently assumed that device, it is being called for, belongs
    to generic power domain and used container_of() on its power
    domain pointer.  Such assumption might not be true always.

2. It iterated over list of generic power domains without holding
   gpd_list_lock mutex thus list could have been modified at the same
   time.

Usage of genpd_lookup_dev() solves both problems as it is safe a call
for non-generic power domains and uses mutex when iterating.

Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
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>
drivers/base/power/domain.c