]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf trace: Don't change const char strings
authorArnaldo Carvalho de Melo <acme@kernel.org>
Thu, 11 Dec 2025 22:17:56 +0000 (19:17 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 17 Dec 2025 12:30:37 +0000 (09:30 -0300)
We got away with this so far but now with fedora 44 complaining about
the return value of strchr et all, lets use strdup for good measure.

Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20251211221756.96294-5-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index baee1f6956001d86f922d9f816acb4d008c38c67..d49c1ae409d77df10170ced18e8e0832ffc2df39 100644 (file)
@@ -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;
 }