Re: [PATCH] cpupower: Avoid uninitialized reads in topology sorting
Shuah <[email protected]> Mon, 3 Aug 2026 10:29:15 -0600
| Newsgroups | org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On 7/29/26 20:07, Ali Ahmet Memis wrote:
>
> get_cpu_topology() allocates core_info with malloc(). If a topology
> attribute disappears while CPUs are being hotplugged, an error path can
> leave core_cpu_list uninitialized. __compare_core_cpu_list() then passes
> the field to strcmp() while sorting the array.
>
> Use calloc() for the array and ignore entries without complete topology
> data when counting cores. Besides avoiding the invalid read, this keeps an
> incomplete entry from being counted as a physical core.
>
> Fixes: f89cb9cba7a2 ("cpupower: Implement CPU physical core querying")
> Cc: [email protected]
> Signed-off-by: Ali Ahmet Memis <[email protected]>
> ---
> Tested with a two-CPU topology mock that makes the second CPU's sysfs
> reads fail. Valgrind reports uninitialized reads before this patch and
> no errors after it.
>
> Build-tested with:
> make -C tools/power/cpupower NLS=false CPUFREQ_BENCH=false
Sorry I am not taking this patch.
Please note that build test just verifies that the code build which
fall way short of testing the changed code.
thanks,
-- Shuah