Skip to contentSkip to conversation

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

PATCH New Jon Hunter 1 participant 1 message Sep 3, 2015

Subsystems (4)
lore
Share & tools
lore

Jon Hunter

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/base/power/domain.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/base/power/domain.c +8 -0
index 27888a90ca98..071b39dc15a0 100644
@@ -1469,6 +1469,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;
@@ -1487,6 +1494,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
 		break;
 	}
 
+out:
 	mutex_unlock(&genpd->lock);
 
 	return ret;
Signature · 1 line
2.1.4