aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/trace-event-parse.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 920b1d58a068..e76214f8d596 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -164,16 +164,15 @@ void parse_ftrace_printk(struct tep_handle *pevent,
164void parse_saved_cmdline(struct tep_handle *pevent, 164void parse_saved_cmdline(struct tep_handle *pevent,
165 char *file, unsigned int size __maybe_unused) 165 char *file, unsigned int size __maybe_unused)
166{ 166{
167 char *comm; 167 char comm[17]; /* Max comm length in the kernel is 16. */
168 char *line; 168 char *line;
169 char *next = NULL; 169 char *next = NULL;
170 int pid; 170 int pid;
171 171
172 line = strtok_r(file, "\n", &next); 172 line = strtok_r(file, "\n", &next);
173 while (line) { 173 while (line) {
174 sscanf(line, "%d %ms", &pid, &comm); 174 if (sscanf(line, "%d %16s", &pid, comm) == 2)
175 tep_register_comm(pevent, comm, pid); 175 tep_register_comm(pevent, comm, pid);
176 free(comm);
177 line = strtok_r(NULL, "\n", &next); 176 line = strtok_r(NULL, "\n", &next);
178 } 177 }
179} 178}