Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM / Domains: Ensure subdomain is not in use before removing

The function pm_genpd_remove_subdomain() removes a subdomain from a
generic PM domain, however, it does not check if the subdomain has any
slave domains or device attached before doing so. Therefore, add a test
to verify that the subdomain does not have any slave domains associated
or any device attached before removing.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Jon Hunter and committed by
Rafael J. Wysocki
30e7a65b 29e47e21

+8
+8
drivers/base/power/domain.c
··· 1473 1473 1474 1474 mutex_lock(&genpd->lock); 1475 1475 1476 + if (!list_empty(&subdomain->slave_links) || subdomain->device_count) { 1477 + pr_warn("%s: unable to remove subdomain %s\n", genpd->name, 1478 + subdomain->name); 1479 + ret = -EBUSY; 1480 + goto out; 1481 + } 1482 + 1476 1483 list_for_each_entry(link, &genpd->master_links, master_node) { 1477 1484 if (link->slave != subdomain) 1478 1485 continue; ··· 1498 1491 break; 1499 1492 } 1500 1493 1494 + out: 1501 1495 mutex_unlock(&genpd->lock); 1502 1496 1503 1497 return ret;