Re: [PATCH] PM: EM: Fix uninitialized power in em_create_perf_table
From: Quentin Perret
Date: Mon Nov 04 2024 - 04:15:25 EST
Hi,
On Monday 04 Nov 2024 at 17:03:51 (+0800), 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
> power is not invalid, initialize power to zero to fix it.
Sounds to me like a driver bug? We check the return value of
active_power() first, so if the callback failed it should tell us.
mtk_cpufreq_get_cpu_power() should only fail if we couldn't find a
cpufreq policy IIUC, so why can't this return -EINVAL instead?
Thanks,
Quentin