Skip to content

Commit c6e83ca

Browse files
krzkrafaeljw
authored andcommitted
PM / Domains: Fix unsafe iteration over modified list of device links
pm_genpd_remove_subdomain() iterates over domain's master_links list and removes matching element thus it has to use safe version of list iteration. Fixes: f721889 ("PM / Domains: Support for generic I/O PM domains (v8)") Cc: 3.1+ <[email protected]> # 3.1+ Signed-off-by: Krzysztof Kozlowski <[email protected]> Acked-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8b55e55 commit c6e83ca

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
@@ -1446,7 +1446,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_add_subdomain);
14461446
int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
14471447
struct generic_pm_domain *subdomain)
14481448
{
1449-
struct gpd_link *link;
1449+
struct gpd_link *l, *link;
14501450
int ret = -EINVAL;
14511451

14521452
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
@@ -1462,7 +1462,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
14621462
goto out;
14631463
}
14641464

1465-
list_for_each_entry(link, &genpd->master_links, master_node) {
1465+
list_for_each_entry_safe(link, l, &genpd->master_links, master_node) {
14661466
if (link->slave != subdomain)
14671467
continue;
14681468

0 commit comments

Comments
 (0)