Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: Move security_perf_event_free() call to __free_event()

Move the freeing of any security state associated with a perf event from
_free_event() to __free_event(), i.e. invoke security_perf_event_free() in
the error paths for perf_event_alloc(). This will allow adding potential
error paths in perf_event_alloc() that can occur after allocating security
state.

Note, kfree() and thus security_perf_event_free() is a nop if
event->security is NULL, i.e. calling security_perf_event_free() even if
security_perf_event_alloc() fails or is never reached is functionality ok.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Xudong Hao <xudong.hao@intel.com>
Link: https://patch.msgid.link/20251206001720.468579-4-seanjc@google.com

authored by

Sean Christopherson and committed by
Peter Zijlstra
991bdf7e b9e52b11

+2 -2
+2 -2
kernel/events/core.c
··· 5601 5601 { 5602 5602 struct pmu *pmu = event->pmu; 5603 5603 5604 + security_perf_event_free(event); 5605 + 5604 5606 if (event->attach_state & PERF_ATTACH_CALLCHAIN) 5605 5607 put_callchain_buffers(); 5606 5608 ··· 5665 5663 irq_work_sync(&event->pending_disable_irq); 5666 5664 5667 5665 unaccount_event(event); 5668 - 5669 - security_perf_event_free(event); 5670 5666 5671 5667 if (event->rb) { 5672 5668 /*