perf record: Zero out mmap_array to fix segfault
authorZhang, Yanmin <yanmin_zhang@linux.intel.com>
Thu, 25 Mar 2010 22:59:01 +0000 (19:59 -0300)
committerIngo Molnar <mingo@elte.hu>
Fri, 26 Mar 2010 07:52:59 +0000 (08:52 +0100)
Reported-by: Li Zefan <lizf@cn.fujitsu.com>
Tested-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Zhang Yanmin <yanmin_zhang@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <1269557941-15617-6-git-send-email-acme@infradead.org>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-record.c
tools/perf/builtin-top.c

index bb5b23db4239802b9281a9b131f7717ceeffe3ad..60ecdd3dd26dd9457e4464c1138803482072d62a 100644 (file)
@@ -751,7 +751,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
        for (i = 0; i < MAX_NR_CPUS; i++) {
                for (j = 0; j < MAX_COUNTERS; j++) {
                        fd[i][j] = malloc(sizeof(int)*thread_num);
-                       mmap_array[i][j] = malloc(
+                       mmap_array[i][j] = zalloc(
                                sizeof(struct mmap_data)*thread_num);
                        if (!fd[i][j] || !mmap_array[i][j])
                                return -ENOMEM;
index 5f3ac9ff354d6c0f8b5840c0dda840b29ddf7739..4abdd9b646b35981d141f9bb3b9e2f710364380c 100644 (file)
@@ -1371,7 +1371,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
        for (i = 0; i < MAX_NR_CPUS; i++) {
                for (j = 0; j < MAX_COUNTERS; j++) {
                        fd[i][j] = malloc(sizeof(int)*thread_num);
-                       mmap_array[i][j] = malloc(
+                       mmap_array[i][j] = zalloc(
                                sizeof(struct mmap_data)*thread_num);
                        if (!fd[i][j] || !mmap_array[i][j])
                                return -ENOMEM;