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

sample-trace-array: Remove trace_array 'sample-instance'

Remove trace_array 'sample-instance' if kthread_run fails
in sample_trace_array_init().

Link: https://lkml.kernel.org/r/20200609135200.2206726-1-wangkefeng.wang@huawei.com

Cc: stable@vger.kernel.org
Fixes: 89ed42495ef4a ("tracing: Sample module to demonstrate kernel access to Ftrace instances.")
Reviewed-by: Divya Indi <divya.indi@oracle.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Kefeng Wang and committed by
Steven Rostedt (VMware)
9fbc01cd e9b7b1c0

+5 -1
+5 -1
samples/ftrace/sample-trace-array.c
··· 115 115 trace_printk_init_buffers(); 116 116 117 117 simple_tsk = kthread_run(simple_thread, NULL, "sample-instance"); 118 - if (IS_ERR(simple_tsk)) 118 + if (IS_ERR(simple_tsk)) { 119 + trace_array_put(tr); 120 + trace_array_destroy(tr); 119 121 return -1; 122 + } 123 + 120 124 return 0; 121 125 } 122 126