]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf sched: Fix thread reference leak in latency_switch_event
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 15:55:29 +0000 (12:55 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 20:34:52 +0000 (17:34 -0300)
commit66ea9de60396a4dea5276bc87025884691876c36
treeb779ea40d5029b7336227db3d3bbf595046a1cdf
parenta5498ccf8079fc91c938f122ff9697b0c526b2fd
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 <sashiko-bot@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-sched.c