From: Arnaldo Carvalho de Melo Date: Thu, 4 Jun 2026 15:55:29 +0000 (-0300) Subject: perf sched: Fix thread reference leak in latency_switch_event X-Git-Tag: v7.2-rc1~60^2~120 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=66ea9de60396a4dea5276bc87025884691876c36;p=thirdparty%2Fkernel%2Flinux.git perf sched: Fix thread reference leak in latency_switch_event In latency_switch_event(), after acquiring thread references for sched_out and sched_in via machine__findnew_thread(), the first add_sched_out_event() failure path does 'return -1', bypassing the out_put label that calls thread__put() on both references. The second and third add_sched_out_event() failures correctly use 'goto out_put'. Fix the first one to match. Fixes: b91fc39f4ad7 ("perf machine: Protect the machine->threads with a rwlock") Reported-by: sashiko-bot Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index e7bd3f331cb8e..13b801496a012 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1180,7 +1180,7 @@ static int latency_switch_event(struct perf_sched *sched, } } if (add_sched_out_event(out_events, prev_state, timestamp)) - return -1; + goto out_put; in_events = thread_atoms_search(&sched->atom_root, sched_in, &sched->cmp_pid); if (!in_events) {