diff mbox

[2/2] PM / Domains: Fix potential NULL pointer dereference

Message ID 1457088915-17284-2-git-send-email-jonathanh@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Jon Hunter March 4, 2016, 10:55 a.m. UTC
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 <jonathanh@nvidia.com>
---
 drivers/base/power/domain.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ulf Hansson March 4, 2016, 11:07 a.m. UTC | #1
On 4 March 2016 at 11:55, Jon Hunter <jonathanh@nvidia.com> wrote:
> 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 <jonathanh@nvidia.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/base/power/domain.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index ea9f2aa3fc33..5bdb42bf40f4 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki March 10, 2016, 11:24 p.m. UTC | #2
On Friday, March 04, 2016 12:07:23 PM Ulf Hansson wrote:
> On 4 March 2016 at 11:55, Jon Hunter <jonathanh@nvidia.com> wrote:
> > 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 <jonathanh@nvidia.com>
> 
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Both this one and the [1/2] applied, thanks!

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index ea9f2aa3fc33..5bdb42bf40f4 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -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 */