tracing: Fix NULL pointer dereference in start_creating
Subsystems (2)
PATCH 1/1 tracing: Fix NULL pointer dereference in start_creating
The event_trace_add_tracer() can fail. In this case, it leads to a crash in start_creating with below call stack. Handle the error scenario properly in trace_array_create_dir.
Call trace: down_write+0x7c/0x204 start_creating.25017+0x6c/0x194 tracefs_create_file+0xc4/0x2b4 init_tracer_tracefs+0x5c/0x940 trace_array_create_dir+0x58/0xb4 trace_array_create+0x1bc/0x2b8 trace_array_get_by_name+0xdc/0x18c
Fixes 4114fbfd
Signed-off-by Kamal Agrawal <[email protected]>
--- kernel/trace/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace.c +3 -1
@@ -9135,8 +9135,10 @@ static int trace_array_create_dir(struct trace_array *tr)return -EINVAL ; ret =event_trace_add_tracer (tr->dir, tr); -if (ret) +if (ret) {tracefs_remove (tr->dir); +return ret; + }init_tracer_tracefs (tr, tr->dir);__update_tracer_options (tr);
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation.
Steven Rostedt
maintainerQuoted 13 lines · On Fri, 30 Jul 2021 18:53:06 +0530 Kamal Agrawal <[email protected]>…
The
event_trace_add_tracer()can fail. In this case, it leads to a crash instart_creatingwith below call stack. Handle the error scenario properly intrace_array_create_dir.Call trace: down_write+0x7c/0x204 start_creating.25017+0x6c/0x194 tracefs_create_file+0xc4/0x2b4 init_tracer_tracefs+0x5c/0x940 trace_array_create_dir+0x58/0xb4 trace_array_create+0x1bc/0x2b8 trace_array_get_by_name+0xdc/0x18c
Quoted 1 line
Fixes 4114fbfd
Thanks, I'll queue this up.
-- Steve
Quoted 21 lines
Signed-off-by Kamal Agrawal <[email protected]>--- kernel/trace/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/trace/trace.c +3
-1@@ -9135,8 +9135,10 @@ static int trace_array_create_dir(struct trace_array *tr)return -EINVAL ; ret =event_trace_add_tracer (tr->dir, tr); -if (ret) +if (ret) {tracefs_remove (tr->dir); +return ret; + }init_tracer_tracefs (tr, tr->dir);__update_tracer_options (tr);