Skip to content

Commit 4384a70

Browse files
storulfrafaeljw
authored andcommitted
PM: domains: Move the verification of in-params from genpd_add_device()
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 <[email protected]> Fixes: f38d1a6 ("PM: domains: Allocate governor data dynamically based on a genpd governor") Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e5d1c87 commit 4384a70

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/base/power/domain.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
16321632

16331633
dev_dbg(dev, "%s()\n", __func__);
16341634

1635-
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
1636-
return -EINVAL;
1637-
16381635
gpd_data = genpd_alloc_dev_data(dev, gd);
16391636
if (IS_ERR(gpd_data))
16401637
return PTR_ERR(gpd_data);
@@ -1676,6 +1673,9 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
16761673
{
16771674
int ret;
16781675

1676+
if (!genpd || !dev)
1677+
return -EINVAL;
1678+
16791679
mutex_lock(&gpd_list_lock);
16801680
ret = genpd_add_device(genpd, dev, dev);
16811681
mutex_unlock(&gpd_list_lock);
@@ -2523,6 +2523,9 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
25232523
struct generic_pm_domain *genpd;
25242524
int ret;
25252525

2526+
if (!dev)
2527+
return -EINVAL;
2528+
25262529
mutex_lock(&gpd_list_lock);
25272530

25282531
genpd = genpd_get_from_provider(genpdspec);

0 commit comments

Comments
 (0)