tracing: Fix allocation of last_cmd in last_cmd_set()
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 14 Feb 2022 17:00:59 +0000 (12:00 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 24 Feb 2022 04:18:54 +0000 (23:18 -0500)
commit9f8e5aee93ed2482638d577a56806b455084b595
tree999b734b468c62dc8c3eba5d12a03fbff8d28552
parent864ea0e10cc90416a01b46f0d47a6f26dc020820
tracing: Fix allocation of last_cmd in last_cmd_set()

The strncat() used in last_cmd_set() includes the nul byte of length of
the string being copied in, when it should only hold the size of the
string being copied (not the nul byte). Change it to subtract the length
of the allocated space and the nul byte to pass that into the strncat().

Also, assign "len" instead of initializing it to zero and its first update
is to do a "+=".

Link: https://lore.kernel.org/all/202202140628.fj6e4w4v-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c