Skip to content

Commit

Permalink
PM: domains: Move the verification of in-params from genpd_add_device()
Browse files Browse the repository at this point in the history
Commit f38d1a6 ("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: f38d1a6 ("PM: domains: Allocate governor data dynamically based on a genpd governor")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
storulf authored and rafaeljw committed Jun 16, 2023
1 parent e5d1c87 commit 4384a70
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4384a70

Please sign in to comment.