Commit a7e2d1bc authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Rafael J. Wysocki

PM / Domains: Fix unsafe iteration over modified list of domains

of_genpd_remove_last() iterates over list of domains and removes
matching element thus it has to use safe version of list iteration.

Fixes: 17926551 (PM / Domains: Add support for removing nested PM domains by provider)
Cc: 4.9+ <stable@vger.kernel.org> # 4.9+
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent b556b15d
...@@ -1980,14 +1980,14 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain); ...@@ -1980,14 +1980,14 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
*/ */
struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
{ {
struct generic_pm_domain *gpd, *genpd = ERR_PTR(-ENOENT); struct generic_pm_domain *gpd, *tmp, *genpd = ERR_PTR(-ENOENT);
int ret; int ret;
if (IS_ERR_OR_NULL(np)) if (IS_ERR_OR_NULL(np))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
mutex_lock(&gpd_list_lock); mutex_lock(&gpd_list_lock);
list_for_each_entry(gpd, &gpd_list, gpd_list_node) { list_for_each_entry_safe(gpd, tmp, &gpd_list, gpd_list_node) {
if (gpd->provider == &np->fwnode) { if (gpd->provider == &np->fwnode) {
ret = genpd_remove(gpd); ret = genpd_remove(gpd);
genpd = ret ? ERR_PTR(ret) : gpd; genpd = ret ? ERR_PTR(ret) : gpd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment