linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pmdomain: qcom-cpr: Fix the return of uninitialized variable
@ 2024-09-26 13:42 Zhang Zekun
  2024-10-02 10:59 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Zekun @ 2024-09-26 13:42 UTC (permalink / raw)
  To: andersson, konradybcio, ulf.hansson, linux-pm, dan.carpenter
  Cc: chenjun102, zhangzekun11

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>
---
 drivers/pmdomain/qcom/cpr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c
index e1fca65b80be..26a60a101e42 100644
--- a/drivers/pmdomain/qcom/cpr.c
+++ b/drivers/pmdomain/qcom/cpr.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pmdomain: qcom-cpr: Fix the return of uninitialized variable
  2024-09-26 13:42 [PATCH] pmdomain: qcom-cpr: Fix the return of uninitialized variable Zhang Zekun
@ 2024-10-02 10:59 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2024-10-02 10:59 UTC (permalink / raw)
  To: Zhang Zekun; +Cc: andersson, konradybcio, linux-pm, dan.carpenter, chenjun102

On Thu, 26 Sept 2024 at 15:56, Zhang Zekun <zhangzekun11@huawei.com> wrote:
>
> 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>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/pmdomain/qcom/cpr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c
> index e1fca65b80be..26a60a101e42 100644
> --- a/drivers/pmdomain/qcom/cpr.c
> +++ b/drivers/pmdomain/qcom/cpr.c
> @@ -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;
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-02 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 13:42 [PATCH] pmdomain: qcom-cpr: Fix the return of uninitialized variable Zhang Zekun
2024-10-02 10:59 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).