From: Swapnil Sapkal Date: Tue, 27 Jan 2026 18:49:57 +0000 (+0000) Subject: perf sched stats: Add NULL check for cd_map X-Git-Tag: v7.0-rc1~16^2~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b03b95b4d71edbb10bfb1588dc59cfea8d13796c;p=thirdparty%2Flinux.git perf sched stats: Add NULL check for cd_map In perf_sched__schedstat_live(), build_cpu_domain_map() returns the pointer to cpu_domain_map which can also be NULL. Add NULL check for the same to avoid NULL pointer dereference. Fixes: 00093b3133984ffe ("perf sched stats: Add support for live mode") 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/builtin-sched.c b/tools/perf/builtin-sched.c index b190e928117c..f5e449bd6823 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -4714,6 +4714,11 @@ static int perf_sched__schedstat_live(struct perf_sched *sched, nr = cpu__max_present_cpu().cpu; cd_map = build_cpu_domain_map(&sv, &md, nr); + if (!cd_map) { + pr_err("Unable to generate cpu-domain relation info"); + goto out; + } + show_schedstat_data(&cpu_head, cd_map, NULL, NULL, false); free_cpu_domain_info(cd_map, sv, nr); out: