In the Linux kernel, the following vulnerability has been resolved:
tracing: Check return value of __registerevent() in tracemoduleaddevents()
tracemoduleadd_events() ignores the return value of __register_event() and unconditionally calls _addeventtotracers() for each event.
If __registerevent() fails (for example, if eventinit() fails), the trace_eventcall is not added to ftraceevents list, but _addeventtotracers() still creates a traceeventfile pointing to it. If module loading subsequently fails and module memory is freed, tracing state retains a stale traceeventcall pointer in traceeventfile, leading to a use-after-free when tracefs or tracing subsystem operations are later executed.
Fix this by checking the return value of __register_event() and only calling _addeventtotracers() if event registration succeeded.