diff options
author | Krzysztof Kozlowski <krzk@kernel.org> | 2017-06-28 16:56:17 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-06-29 01:24:35 +0200 |
commit | 8b55e55ee44356d68f4a7ee4b11f9cbb1f5958cc (patch) | |
tree | a64beb938e255e47a048857c8b08329a63bd2783 /drivers/base/power | |
parent | PM / Domains: Call driver's noirq callbacks (diff) | |
download | linux-8b55e55ee44356d68f4a7ee4b11f9cbb1f5958cc.tar.xz linux-8b55e55ee44356d68f4a7ee4b11f9cbb1f5958cc.zip |
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>
Diffstat (limited to 'drivers/base/power')
-rw-r--r-- | drivers/base/power/domain.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index bbbb1d72395b..b8d7907ee101 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1148,8 +1148,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; - genpd = dev_to_genpd(dev); - if (!pm_genpd_present(genpd)) + genpd = genpd_lookup_dev(dev); + if (!genpd) return; if (suspend) { |