linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Perret <qperret@google.com>
To: Lukasz Luba <lukasz.luba@arm.com>
Cc: Jinjie Ruan <ruanjinjie@huawei.com>,
	rafael@kernel.org, pavel@ucw.cz, len.brown@intel.com,
	linux-pm@vger.kernel.org, daniel.lezcano@linaro.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM: EM: Fix uninitialized power in em_create_perf_table
Date: Mon, 4 Nov 2024 09:16:05 +0000	[thread overview]
Message-ID: <ZyiQ1YS81ZjE1Qlu@google.com> (raw)
In-Reply-To: <3386f37a-55f4-43e0-a991-7cf4ece2e55a@arm.com>

On Monday 04 Nov 2024 at 09:14:36 (+0000), Lukasz Luba wrote:
> Hi Jinjie,
> 
> On 11/4/24 09:03, Jinjie Ruan wrote:
> > In em_create_perf_table(), power is uninitialized and passed the pointer
> > to active_power() hook, but the hook function may not assign it and
> > return 0, such as mtk_cpufreq_get_cpu_power(), so the later zero check for
> 
> Please fix the driver. I have checked that function. It must return
> -EINVAL when the 'policy' is not found. We cannot progress with power=0.
> 
> 
> > power is not invalid, initialize power to zero to fix it.
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 7d9895c7fbfc ("PM / EM: introduce em_dev_register_perf_domain function")
> > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> > ---
> >   kernel/power/energy_model.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> > index 927cc55ba0b3..866a3e9c05b2 100644
> > --- a/kernel/power/energy_model.c
> > +++ b/kernel/power/energy_model.c
> > @@ -344,7 +344,7 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
> >   				struct em_data_callback *cb,
> >   				unsigned long flags)
> >   {
> > -	unsigned long power, freq, prev_freq = 0;
> > +	unsigned long power = 0, freq, prev_freq = 0;
> >   	int nr_states = pd->nr_perf_states;
> >   	int i, ret;
> 
> 
> This patch proposal is just a workaround.
> 
> When you send a patch to that MTK driver, I can review it for you so
> please add me on CC.

We raced, but +1 to the above :-)

  reply	other threads:[~2024-11-04  9:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04  9:03 [PATCH] PM: EM: Fix uninitialized power in em_create_perf_table Jinjie Ruan
2024-11-04  9:14 ` Lukasz Luba
2024-11-04  9:16   ` Quentin Perret [this message]
2024-11-04  9:19   ` Jinjie Ruan
2024-11-04  9:15 ` Quentin Perret

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZyiQ1YS81ZjE1Qlu@google.com \
    --to=qperret@google.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=ruanjinjie@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).