Skip to content

Commit

Permalink
PM / Domains: Ensure subdomain is not in use before removing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jon Hunter authored and Rafael J. Wysocki committed Sep 5, 2015
1 parent 29e47e2 commit 30e7a65
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,13 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,

mutex_lock(&genpd->lock);

if (!list_empty(&subdomain->slave_links) || subdomain->device_count) {
pr_warn("%s: unable to remove subdomain %s\n", genpd->name,
subdomain->name);
ret = -EBUSY;
goto out;
}

list_for_each_entry(link, &genpd->master_links, master_node) {
if (link->slave != subdomain)
continue;
Expand All @@ -1491,6 +1498,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
break;
}

out:
mutex_unlock(&genpd->lock);

return ret;
Expand Down

0 comments on commit 30e7a65

Please sign in to comment.