summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-trace.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index baee1f695600..d49c1ae409d7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -5173,8 +5173,8 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
int unset __maybe_unused)
{
struct trace *trace = (struct trace *)opt->value;
- const char *s = str;
- char *sep = NULL, *lists[2] = { NULL, NULL, };
+ const char *s;
+ char *strd, *sep = NULL, *lists[2] = { NULL, NULL, };
int len = strlen(str) + 1, err = -1, list, idx;
char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
char group_name[PATH_MAX];
@@ -5183,6 +5183,10 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
if (strace_groups_dir == NULL)
return -1;
+ s = strd = strdup(str);
+ if (strd == NULL)
+ return -1;
+
if (*s == '!') {
++s;
trace->not_ev_qualifier = true;
@@ -5257,8 +5261,7 @@ out:
free(strace_groups_dir);
free(lists[0]);
free(lists[1]);
- if (sep)
- *sep = ',';
+ free(strd);
return err;
}