PM / Domains: Fix removal of a subdomain
Subsystems (5)
Jon Hunter
maintainerPATCH 1/2 PM / Domains: Fix removal of a subdomain
Commit 30e7a65b3fdb ("PM / Domains: Ensure subdomain is not in use before removing") added a test to ensure that a subdomain is not a master to another subdomain or if any devices are using the subdomain before removing. This change incorrectly used the "slave_links" list to determine if the subdomain is a master to another subdomain, where it should have been using the "master_links" list instead. The "slave_links" list will never be empty for a subdomain and so a subdomain can never be removed. Fix this by testing if the "master_links" list is empty instead.
---
This first was originally included in the series to add PM domain support [0]. I am separating this for now, as it can be merged independently.
[0] http://marc.info/?l=linux-pm&m=145650174525180&w=2
drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
@@ -1382,7 +1382,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,mutex_lock (&subdomain->lock);mutex_lock_nested (&genpd->lock,SINGLE_DEPTH_NESTING ); -if (!list_empty (&subdomain->slave_links) || subdomain->device_count) { +if (!list_empty (&subdomain->master_links) || subdomain->device_count) {pr_warn ("%s: unable to remove subdomain %s\n" , genpd->name, subdomain->name); ret = -EBUSY ;
Signature · 1 line
2.1.4
PATCH 2/2 PM / Domains: Fix potential NULL pointer dereference
In reply to a message not in the archiveIn the function of_genpd_get_from_provider(), we never check to see if the argument 'genpdspec' is NULL before dereferencing it. Add error checking to handle any NULL pointers.
--- drivers/base/power/domain.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/base/power/domain.c +3 -0
@@ -1686,6 +1686,9 @@ struct generic_pm_domain *of_genpd_get_from_provider(struct generic_pm_domain *genpd =ERR_PTR (-ENOENT );struct of_genpd_provider *provider; +if (!genpdspec) +return ERR_PTR (-EINVAL ); +mutex_lock (&of_genpd_mutex);/* Check if we have such a provider in our array */
Signature · 1 line
2.1.4
Ulf Hansson
Acked-byRe: [PATCH 2/2] PM / Domains: Fix potential NULL pointer dereference
In reply to a message not in the archiveQuoted 5 lines · Jon Hunter
In the function
of_genpd_get_from_provider(), we never check to see if the argument 'genpdspec' is NULL before dereferencing it. Add error checking to handle any NULL pointers.Signed-off-by Jon Hunter <[email protected]>
Kind regards
Uffe
Quoted 21 lines
--- drivers/base/power/domain.c | 3 +++ 1 file changed, 3 insertions(+)drivers/base/power/domain.c +3
-1@@ -1686,6 +1686,9 @@ struct generic_pm_domain *of_genpd_get_from_provider(struct generic_pm_domain *genpd =ERR_PTR (-ENOENT );struct of_genpd_provider *provider; +if (!genpdspec) +return ERR_PTR (-EINVAL ); +mutex_lock (&of_genpd_mutex);/* Check if we have such a provider in our array */ --2.1.4
Re: [PATCH 2/2] PM / Domains: Fix potential NULL pointer dereference
In reply to a message not in the archiveQuoted 8 lines · Ulf Hansson
Quoted 5 lines · Jon Hunter
In the function
of_genpd_get_from_provider(), we never check to see if the argument 'genpdspec' is NULL before dereferencing it. Add error checking to handle any NULL pointers.Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>
Both this one and the [1/2] applied, thanks!
Rafael