Skip to content

Commit a7e2d1b

Browse files
krzkrafaeljw
authored andcommitted
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: 1792655 (PM / Domains: Add support for removing nested PM domains by provider) Cc: 4.9+ <[email protected]> # 4.9+ Signed-off-by: Krzysztof Kozlowski <[email protected]> Acked-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b556b15 commit a7e2d1b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/base/power/domain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,14 +1980,14 @@ EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
19801980
*/
19811981
struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
19821982
{
1983-
struct generic_pm_domain *gpd, *genpd = ERR_PTR(-ENOENT);
1983+
struct generic_pm_domain *gpd, *tmp, *genpd = ERR_PTR(-ENOENT);
19841984
int ret;
19851985

19861986
if (IS_ERR_OR_NULL(np))
19871987
return ERR_PTR(-EINVAL);
19881988

19891989
mutex_lock(&gpd_list_lock);
1990-
list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
1990+
list_for_each_entry_safe(gpd, tmp, &gpd_list, gpd_list_node) {
19911991
if (gpd->provider == &np->fwnode) {
19921992
ret = genpd_remove(gpd);
19931993
genpd = ret ? ERR_PTR(ret) : gpd;

0 commit comments

Comments
 (0)