]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf sched: Fix NULL dereference in latency_runtime_event
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 15:56:02 +0000 (12:56 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 20:34:52 +0000 (17:34 -0300)
commit8cbca8a480e15f6326ce94287570993f27a4b2d5
treec7b39b070cdfc6329e9a8fc47246c4ea2c5f0d81
parent66ea9de60396a4dea5276bc87025884691876c36
perf sched: Fix NULL dereference in latency_runtime_event

latency_runtime_event() passes the return value of
machine__findnew_thread() directly to thread_atoms_search() at line
1216, before checking for NULL at line 1220.  thread_atoms_search()
calls pid_cmp() which dereferences the thread pointer via
thread__tid(), causing a NULL pointer dereference if the allocation
fails.

All other callers of thread_atoms_search() in this file
(latency_switch_event, latency_wakeup_event,
latency_migrate_task_event) correctly check for NULL first.

Move the atoms assignment after the NULL check to match the pattern
used by the other callers.

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