Skip to content

Commit 588bebb

Browse files
Masami Hiramatsufweisbec
authored andcommitted
ftrace: Fix trace_add_event_call() to initialize list
Handle failure path in trace_add_event_call() to fix the below bug which occurred when I tried to add invalid event twice. Could not create debugfs 'kmalloc' directory Failed to register kprobe event: kmalloc Faild to register probe event(-1) ------------[ cut here ]------------ WARNING: at /home/mhiramat/ksrc/random-tracing/lib/list_debug.c:26 __list_add+0x27/0x5c() Hardware name: list_add corruption. next->prev should be prev (c07d78cc), but was 00001000. (next=d854236c). Modules linked in: sunrpc uinput virtio_net virtio_balloon i2c_piix4 pcspkr i2c_core virtio_blk virtio_pci virtio_ring virtio [last unloaded: scsi_wait_scan] Pid: 1394, comm: tee Not tainted 2.6.31-rc9 #51 Call Trace: [<c0438424>] warn_slowpath_common+0x65/0x7c [<c05371b3>] ? __list_add+0x27/0x5c [<c043846f>] warn_slowpath_fmt+0x24/0x27 [<c05371b3>] __list_add+0x27/0x5c [<c047f050>] list_add+0xa/0xc [<c047f8f5>] trace_add_event_call+0x60/0x97 [<c0483133>] command_trace_probe+0x42c/0x51b [<c044a1b3>] ? remove_wait_queue+0x22/0x27 [<c042a9c0>] ? __wake_up+0x32/0x3b [<c04832f6>] probes_write+0xd4/0x10a [<c0483222>] ? probes_write+0x0/0x10a [<c04b27a9>] vfs_write+0x80/0xdf [<c04b289c>] sys_write+0x3b/0x5d [<c0670d41>] syscall_call+0x7/0xb ---[ end trace 2b962b5dc1fdc07d ]--- Signed-off-by: Masami Hiramatsu <[email protected]> Acked-by: Steven Rostedt <[email protected]> Cc: Jim Keniston <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Frank Ch. Eigler <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Baron <[email protected]> Cc: K.Prasad <[email protected]> Cc: Lai Jiangshan <[email protected]> Cc: Li Zefan <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Srikar Dronamraju <[email protected]> Cc: Tom Zanussi <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 2d5e067 commit 588bebb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/trace/trace_events.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,12 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
10101010
return -ENOENT;
10111011

10121012
list_add(&call->list, &ftrace_events);
1013-
return event_create_dir(call, d_events, &ftrace_event_id_fops,
1013+
ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
10141014
&ftrace_enable_fops, &ftrace_event_filter_fops,
10151015
&ftrace_event_format_fops);
1016+
if (ret < 0)
1017+
list_del(&call->list);
1018+
return ret;
10161019
}
10171020

10181021
/* Add an additional event_call dynamically */

0 commit comments

Comments
 (0)