From: tip-bot for David Ahern <dsahern@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
mingo@kernel.org, penberg@kernel.org, srikar@linux.vnet.ibm.com,
dsahern@gmail.com, irina.tirdea@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf probe: Make a copy of exec path for passing to basename
Date: Sun, 9 Sep 2012 02:00:13 -0700 [thread overview]
Message-ID: <tip-1fb89448871500e5d5e7ad93d6dae68ee4fa464a@git.kernel.org> (raw)
In-Reply-To: <1347116812-93646-3-git-send-email-dsahern@gmail.com>
Commit-ID: 1fb89448871500e5d5e7ad93d6dae68ee4fa464a
Gitweb: http://git.kernel.org/tip/1fb89448871500e5d5e7ad93d6dae68ee4fa464a
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 8 Sep 2012 09:06:51 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 8 Sep 2012 17:15:04 -0300
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>
---
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 0dda25d..e8c72de 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)
function = NULL;
}
if (!pev->group) {
- char *ptr1, *ptr2;
+ char *ptr1, *ptr2, *exec_copy;
pev->group = zalloc(sizeof(char *) * 64);
- ptr1 = strdup(basename(exec));
+ exec_copy = strdup(exec);
+ if (!exec_copy) {
+ ret = -ENOMEM;
+ pr_warning("Failed to copy exec string.\n");
+ goto out;
+ }
+
+ ptr1 = strdup(basename(exec_copy));
if (ptr1) {
ptr2 = strpbrk(ptr1, "-._");
if (ptr2)
@@ -2319,6 +2326,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
ptr1);
free(ptr1);
}
+ free(exec_copy);
}
free(pp->function);
pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS);
next prev parent reply other threads:[~2012-09-09 9:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-08 15:06 [PATCH 0/3] perf tool: basename cleanups David Ahern
2012-09-08 15:06 ` [PATCH 1/3] perf annotate: make a copy of filename for passing to basename David Ahern
2012-09-09 8:59 ` [tip:perf/core] perf annotate: Make " tip-bot for David Ahern
2012-09-08 15:06 ` [PATCH 2/3] perf probe: make a copy of exec path " David Ahern
2012-09-09 9:00 ` tip-bot for David Ahern [this message]
2012-09-08 15:06 ` [PATCH 3/3] perf tool: remove BIONIC wrapper around libgen.h David Ahern
2012-09-09 9:01 ` [tip:perf/core] perf symbols: Remove BIONIC wrapper around libgen. h tip-bot for David Ahern
2012-09-08 16:24 ` [PATCH 0/3] perf tool: basename cleanups Pekka Enberg
2012-09-08 22:25 ` Irina Tirdea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-1fb89448871500e5d5e7ad93d6dae68ee4fa464a@git.kernel.org \
--to=dsahern@gmail.com \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=irina.tirdea@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=penberg@kernel.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox