diff options
author | Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> | 2023-07-21 15:46:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-09-13 10:42:28 +0300 |
commit | 5d343b49078de9fbdce2dd0ec894f5b8daeb1031 (patch) | |
tree | dc6f335513bffd9979d313662ebccc2e26b5f7ff /drivers | |
parent | e0322a255a2242dbe4686b6176b3c83dea490529 (diff) | |
download | linux-5d343b49078de9fbdce2dd0ec894f5b8daeb1031.tar.xz |
OPP: Fix passing 0 to PTR_ERR in _opp_attach_genpd()
[ Upstream commit d920920f85a82c1c806a4143871a0e8f534732f2 ]
If dev_pm_domain_attach_by_name() returns NULL, then 0 will be passed to
PTR_ERR() as reported by the smatch warning below:
drivers/opp/core.c:2456 _opp_attach_genpd() warn: passing zero to 'PTR_ERR'
Fix it by checking for the non-NULL virt_dev pointer before passing it to
PTR_ERR. Otherwise return -ENODEV.
Fixes: 4ea9496cbc95 ("opp: Fix error check in dev_pm_opp_attach_genpd()")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/opp/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index d707214069ca..f0d70ecc0271 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2372,7 +2372,7 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, virt_dev = dev_pm_domain_attach_by_name(dev, *name); if (IS_ERR_OR_NULL(virt_dev)) { - ret = PTR_ERR(virt_dev) ? : -ENODEV; + ret = virt_dev ? PTR_ERR(virt_dev) : -ENODEV; dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret); goto err; } |