Re: [PATCH] cpupower: Avoid uninitialized reads in topology sorting

Shuah <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.power-management.general,gmane.linux.kernel.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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.