Skip to content

Commit

Permalink
PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_s…
Browse files Browse the repository at this point in the history
…tate()

The dev_pm_genpd_set_performance_state() could in principle be called for a
device that has a different PM domain type attached than a genpd. This
would lead to a problem as dev_to_genpd() uses the container_of macro.

Address this problem by using dev_to_genpd_safe() instead.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ulf Hansson authored and Rafael J. Wysocki committed Sep 2, 2019
1 parent b3ad17c commit 3ea4ca9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
unsigned int prev;
int ret;

genpd = dev_to_genpd(dev);
if (IS_ERR(genpd))
genpd = dev_to_genpd_safe(dev);
if (!genpd)
return -ENODEV;

if (unlikely(!genpd->set_performance_state))
Expand Down

0 comments on commit 3ea4ca9

Please sign in to comment.