From: tzanussi@gmail.com
To: linux-kernel@vger.kernel.org
Cc: acme@ghostprotocols.net, mingo@elte.hu, fweisbec@gmail.com
Subject: [PATCH 1/7] perf trace scripting: fix some small memory leaks and missing error checks
Date: Tue, 9 Nov 2010 15:18:16 -0600 [thread overview]
Message-ID: <1289337502-2492-2-git-send-email-tzanussi@gmail.com> (raw)
In-Reply-To: <1289337502-2492-1-git-send-email-tzanussi@gmail.com>
From: Tom Zanussi <tom.zanussi@linux.intel.com>
Free the other two fields of script_desc which somehow got overlooked,
free malloc'ed args in case exec fails, and add missing checks for
failed mallocs.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
tools/perf/builtin-trace.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2f8df45..368e624 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -337,6 +337,8 @@ static struct script_desc *script_desc__new(const char *name)
static void script_desc__delete(struct script_desc *s)
{
free(s->name);
+ free(s->half_liner);
+ free(s->args);
free(s);
}
@@ -626,6 +628,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
close(live_pipe[0]);
__argv = malloc(6 * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
+
__argv[0] = "/bin/sh";
__argv[1] = record_script_path;
__argv[2] = "-q";
@@ -634,6 +639,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
__argv[5] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}
@@ -641,6 +647,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
close(live_pipe[1]);
__argv = malloc((argc + 3) * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
__argv[0] = "/bin/sh";
__argv[1] = report_script_path;
for (i = 2; i < argc; i++)
@@ -650,6 +658,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
__argv[i++] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}
@@ -661,6 +670,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
}
__argv = malloc((argc + 1) * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
__argv[0] = "/bin/sh";
__argv[1] = script_path;
for (i = 3; i < argc; i++)
@@ -668,7 +679,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
__argv[argc - 1] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}
--
Tom Zanussi, Intel Open Source Technology Center
next prev parent reply other threads:[~2010-11-09 21:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 21:18 [PATCH 0/7] perf trace command-line cleanup tzanussi
2010-11-09 21:18 ` tzanussi [this message]
2010-11-09 21:18 ` [PATCH 2/7] perf trace scripting: remove system-wide param from shell scripts tzanussi
2010-11-09 21:18 ` [PATCH 3/7] perf record: make the record options available outside perf record tzanussi
2010-11-09 21:18 ` [PATCH 4/7] perf trace record: handle commands correctly tzanussi
2010-11-09 21:18 ` [PATCH 5/7] perf trace: live-mode command-line cleanup tzanussi
2010-11-09 21:18 ` [PATCH 6/7] perf trace: update Documentation with new perf trace variants tzanussi
2010-11-09 21:18 ` [PATCH 7/7] perf trace: update usage tzanussi
2010-11-09 21:38 ` [PATCH 0/7] perf trace command-line cleanup Arnaldo Carvalho de Melo
2010-11-10 7:32 ` Ingo Molnar
2010-11-10 18:09 ` Tom Zanussi
2010-11-10 18:10 [PATCH 0/7] perf trace command-line cleanup, v2 tzanussi
2010-11-10 18:10 ` [PATCH 1/7] perf trace scripting: fix some small memory leaks and missing error checks tzanussi
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=1289337502-2492-2-git-send-email-tzanussi@gmail.com \
--to=tzanussi@gmail.com \
--cc=acme@ghostprotocols.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
Powered by JetHome