]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pmdomain: qcom-cpr: Fix the return of uninitialized variable
authorZhang Zekun <zhangzekun11@huawei.com>
Thu, 26 Sep 2024 13:42:11 +0000 (21:42 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 2 Oct 2024 10:38:53 +0000 (12:38 +0200)
The of_property_read_u64() can fail and remain the variable uninitialized,
which will then be returned. Initializing the variable "rate" to zero to
fix this problem.

Fixes: 181c8148556a ("pmdomain: qcom-cpr: Use scope based of_node_put() to simplify code.")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/455a6a49-41d2-4a20-9a31-f57ee7a67920@huawei.com/T/#m0a62b501b453a6d6e94c52a428a66f65b5422c65
Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240926134211.45394-1-zhangzekun11@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/pmdomain/qcom/cpr.c

index e1fca65b80becbe9757f56862ae329478b3b7fe4..26a60a101e42a03919fe4117b45fba3f85315e19 100644 (file)
@@ -1052,7 +1052,7 @@ static unsigned long cpr_get_opp_hz_for_req(struct dev_pm_opp *ref,
                        of_parse_phandle(child_np, "required-opps", 0);
 
                if (child_req_np == ref_np) {
-                       u64 rate;
+                       u64 rate = 0;
 
                        of_property_read_u64(child_np, "opp-hz", &rate);
                        return (unsigned long) rate;