From: Swapnil Sapkal Date: Tue, 27 Jan 2026 18:49:56 +0000 (+0000) Subject: perf util: Fix NULL check in cpumask_to_cpulist() X-Git-Tag: v7.0-rc1~16^2~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05134d15375ce9fc57a91453999729d861efe9f9;p=thirdparty%2Flinux.git perf util: Fix NULL check in cpumask_to_cpulist() The function cpumask_to_cpulist() allocates memory with calloc() and stores the result in 'bm', but then incorrectly checks 'cpumask' for NULL instead of 'bm'. This means that if the allocation fails, the function will dereference a NULL pointer when trying to access 'bm'. Fix the check to test the correct variable 'bm'. Fixes: d40c68a49f69c9bd ("perf header: Support CPU DOMAIN relation info") Reviewed-by: Shrikanth Hegde Signed-off-by: Swapnil Sapkal Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Anubhav Shelat Cc: Chen Yu Cc: Gautham Shenoy Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Thomas Falcon Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 94f5a2ece245..8b893de35f77 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -279,7 +279,7 @@ void cpumask_to_cpulist(char *cpumask, char *cpulist) return; bm = calloc(bm_size, sizeof(unsigned long)); - if (!cpumask) + if (!bm) goto free_bm; for (i = 0; i < bm_size; i++) {