opp: Fix return in _opp_add_static_v2()
authorYueHaibing <yuehaibing@huawei.com>
Fri, 8 Oct 2021 07:46:52 +0000 (15:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 13:04:22 +0000 (14:04 +0100)
[ Upstream commit 27ff8187f13ecfec8a26fb1928e906f46f326cc5 ]

Fix sparse warning:
drivers/opp/of.c:924 _opp_add_static_v2() warn: passing zero to 'ERR_PTR'

For duplicate OPPs 'ret' be set to zero.

Fixes: deac8703da5f ("PM / OPP: _of_add_opp_table_v2(): increment count only if OPP is added")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/opp/of.c

index f83f4f6d703499f62b95f93b7792a5f00a049edb..5de46aa99d2432d05f45292501e0baf5f8194c8b 100644 (file)
@@ -827,7 +827,7 @@ free_required_opps:
 free_opp:
        _opp_free(new_opp);
 
-       return ERR_PTR(ret);
+       return ret ? ERR_PTR(ret) : NULL;
 }
 
 /* Initializes OPP tables based on new bindings */