From: Ulf Hansson Date: Thu, 29 Aug 2019 14:48:15 +0000 (+0200) Subject: PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3ea4ca9267cf5d02149f7d8a11d8b4c82723a668;p=linux.git PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state() 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 Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 59d6f183d0bbd..cc85e87eaf055 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))