diff options
author | David Ahern <dsahern@gmail.com> | 2012-09-08 11:06:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-08 16:15:04 -0400 |
commit | 1fb89448871500e5d5e7ad93d6dae68ee4fa464a (patch) | |
tree | 3092d01f4007951b9776379695b6917a8ccf4145 | |
parent | bfd14b9a7231e7cf77520bca1848c40c6b6360ae (diff) |
perf probe: Make a copy of exec path for passing to basename
The basename function may modify the string passed to it, so the string
should not be marked const.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1347116812-93646-3-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/probe-event.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 0dda25d82d06..e8c72de0f70c 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -2307,10 +2307,17 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec) | |||
2307 | function = NULL; | 2307 | function = NULL; |
2308 | } | 2308 | } |
2309 | if (!pev->group) { | 2309 | if (!pev->group) { |
2310 | char *ptr1, *ptr2; | 2310 | char *ptr1, *ptr2, *exec_copy; |
2311 | 2311 | ||
2312 | pev->group = zalloc(sizeof(char *) * 64); | 2312 | pev->group = zalloc(sizeof(char *) * 64); |
2313 | ptr1 = strdup(basename(exec)); | 2313 | exec_copy = strdup(exec); |
2314 | if (!exec_copy) { | ||
2315 | ret = -ENOMEM; | ||
2316 | pr_warning("Failed to copy exec string.\n"); | ||
2317 | goto out; | ||
2318 | } | ||
2319 | |||
2320 | ptr1 = strdup(basename(exec_copy)); | ||
2314 | if (ptr1) { | 2321 | if (ptr1) { |
2315 | ptr2 = strpbrk(ptr1, "-._"); | 2322 | ptr2 = strpbrk(ptr1, "-._"); |
2316 | if (ptr2) | 2323 | if (ptr2) |
@@ -2319,6 +2326,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec) | |||
2319 | ptr1); | 2326 | ptr1); |
2320 | free(ptr1); | 2327 | free(ptr1); |
2321 | } | 2328 | } |
2329 | free(exec_copy); | ||
2322 | } | 2330 | } |
2323 | free(pp->function); | 2331 | free(pp->function); |
2324 | pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS); | 2332 | pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS); |