trace-cmd: Initialize option list earlier in create_file_fd()

The error paths of create_file_fd() after the handle is allocated, jumps
to the out_free label. This will call tracecmd_output_close(), which will
clean up the allocated tracecmd_output handle. This includes the options
list. But there's two error paths that will jump to out_free before the
options list is initialized. If an error occurs in one of these two
locations, then walking the option list will cause a segfault.

Initialize the option list immediately after the allocation of the handle
and before any of the error paths that jump to out_free.

Link: https://lore.kernel.org/linux-trace-devel/20210621221814.200894db@oasis.local.home

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 file changed