[2/2] PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state()
diff mbox series

Message ID 20190829144815.686-1-ulf.hansson@linaro.org
State Queued
Delegated to: Rafael Wysocki
Headers show
Series
  • [1/2] PM / Domains: Simplify genpd_lookup_dev()
Related show

Commit Message

Ulf Hansson Aug. 29, 2019, 2:48 p.m. UTC
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>
---
 drivers/base/power/domain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 27592b73061d..2650ae2f46fd 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -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))