* [PATCH] PM: domains: Move the verification of in-params from genpd_add_device()
@ 2023-05-30 9:55 Ulf Hansson
2023-06-16 17:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hansson @ 2023-05-30 9:55 UTC (permalink / raw)
To: Rafael J . Wysocki, linux-pm
Cc: Kevin Hilman, Ulf Hansson, Dan Carpenter, linux-arm-kernel, linux-kernel
The commit f38d1a6d0025 ("PM: domains: Allocate governor data dynamically
based on a genpd governor") started to use the in-parameters in
genpd_add_device(), without first doing a verification of them.
This isn't really a big problem, as most callers do a verification already.
Therefore, let's drop the verification from genpd_add_device() and make
sure all the callers take care of it instead.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: f38d1a6d0025 ("PM: domains: Allocate governor data dynamically based on a genpd governor")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/base/power/domain.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 51b9d4eaab5e..5cb2023581d4 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1632,9 +1632,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
dev_dbg(dev, "%s()\n", __func__);
- if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
- return -EINVAL;
-
gpd_data = genpd_alloc_dev_data(dev, gd);
if (IS_ERR(gpd_data))
return PTR_ERR(gpd_data);
@@ -1676,6 +1673,9 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
{
int ret;
+ if (!genpd || !dev)
+ return -EINVAL;
+
mutex_lock(&gpd_list_lock);
ret = genpd_add_device(genpd, dev, dev);
mutex_unlock(&gpd_list_lock);
@@ -2523,6 +2523,9 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
struct generic_pm_domain *genpd;
int ret;
+ if (!dev)
+ return -EINVAL;
+
mutex_lock(&gpd_list_lock);
genpd = genpd_get_from_provider(genpdspec);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PM: domains: Move the verification of in-params from genpd_add_device()
2023-05-30 9:55 [PATCH] PM: domains: Move the verification of in-params from genpd_add_device() Ulf Hansson
@ 2023-06-16 17:40 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-06-16 17:40 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J . Wysocki, linux-pm, Kevin Hilman, Dan Carpenter,
linux-arm-kernel, linux-kernel
On Tue, May 30, 2023 at 11:55 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> The commit f38d1a6d0025 ("PM: domains: Allocate governor data dynamically
> based on a genpd governor") started to use the in-parameters in
> genpd_add_device(), without first doing a verification of them.
>
> This isn't really a big problem, as most callers do a verification already.
> Therefore, let's drop the verification from genpd_add_device() and make
> sure all the callers take care of it instead.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Fixes: f38d1a6d0025 ("PM: domains: Allocate governor data dynamically based on a genpd governor")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/base/power/domain.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 51b9d4eaab5e..5cb2023581d4 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1632,9 +1632,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
>
> dev_dbg(dev, "%s()\n", __func__);
>
> - if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
> - return -EINVAL;
> -
> gpd_data = genpd_alloc_dev_data(dev, gd);
> if (IS_ERR(gpd_data))
> return PTR_ERR(gpd_data);
> @@ -1676,6 +1673,9 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
> {
> int ret;
>
> + if (!genpd || !dev)
> + return -EINVAL;
> +
> mutex_lock(&gpd_list_lock);
> ret = genpd_add_device(genpd, dev, dev);
> mutex_unlock(&gpd_list_lock);
> @@ -2523,6 +2523,9 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
> struct generic_pm_domain *genpd;
> int ret;
>
> + if (!dev)
> + return -EINVAL;
> +
> mutex_lock(&gpd_list_lock);
>
> genpd = genpd_get_from_provider(genpdspec);
> --
Applied as 6.5 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-16 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 9:55 [PATCH] PM: domains: Move the verification of in-params from genpd_add_device() Ulf Hansson
2023-06-16 17:40 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).