perf tools: Catch a few uncheck calloc/malloc's
A message that is not in the archive (sent off-list or not yet received): [email protected]
Commit-ID: ce47dc56a2241dc035160a85bc5e34283cdd622c Gitweb: http://git.kernel.org/tip/ce47dc56a2241dc035160a85bc5e34283cdd622c Author: Chris Samuel <[email protected]> AuthorDate: Sat, 13 Nov 2010 13:35:06 +1100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 6 Dec 2010 12:52:35 -0200
perf tools: Catch a few uncheck calloc/malloc's
There were a few stray calloc()'s and malloc()'s which were not having their return values checked for success.
As the calling code either already coped with failure or didn't actually care we just return -ENOMEM at that point.
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Signed-off-by Chris Samuel <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-kmem.c | 3 +++ tools/perf/builtin-lock.c | 3 +++ tools/perf/builtin-sched.c | 3 +++ tools/perf/builtin-timechart.c | 3 +++ tools/perf/util/header.c | 3 +++ 5 files changed, 15 insertions(+), 0 deletions(-)
tools/perf/builtin-kmem.c +3 -0
@@ -736,6 +736,9 @@ static int __cmd_record(int argc, const char **argv) rec_argc =ARRAY_SIZE (record_args) + argc -1 ; rec_argv =calloc (rec_argc +1 ,sizeof (char *)); +if (rec_argv ==NULL ) +return -ENOMEM ; +for (i =0 ; i <ARRAY_SIZE (record_args); i++) rec_argv[i] =strdup (record_args[i]);
tools/perf/builtin-lock.c +3 -0
@@ -943,6 +943,9 @@ static int __cmd_record(int argc, const char **argv) rec_argc =ARRAY_SIZE (record_args) + argc -1 ; rec_argv =calloc (rec_argc +1 ,sizeof (char *)); +if (rec_argv ==NULL ) +return -ENOMEM ; +for (i =0 ; i <ARRAY_SIZE (record_args); i++) rec_argv[i] =strdup (record_args[i]);
tools/perf/builtin-sched.c +3 -0
@@ -1860,6 +1860,9 @@ static int __cmd_record(int argc, const char **argv) rec_argc =ARRAY_SIZE (record_args) + argc -1 ; rec_argv =calloc (rec_argc +1 ,sizeof (char *)); +if (rec_argv) +return -ENOMEM ; +for (i =0 ; i <ARRAY_SIZE (record_args); i++) rec_argv[i] =strdup (record_args[i]);
tools/perf/builtin-timechart.c +3 -0
@@ -989,6 +989,9 @@ static int __cmd_record(int argc, const char **argv) rec_argc =ARRAY_SIZE (record_args) + argc -1 ; rec_argv =calloc (rec_argc +1 ,sizeof (char *)); +if (rec_argv ==NULL ) +return -ENOMEM ; +for (i =0 ; i <ARRAY_SIZE (record_args); i++) rec_argv[i] =strdup (record_args[i]);
tools/perf/util/header.c +3 -0
@@ -1005,6 +1005,9 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, ev =malloc (size); +if (ev ==NULL ) +return -ENOMEM ; + ev->attr.attr = *attr;memcpy (ev->attr.id, id, ids *sizeof (u64));