[PATCH 23/74] perf kvm: Initialize file_name var to fix segfault

From: Arnaldo Carvalho de Melo
Date: Thu Jan 24 2013 - 15:18:07 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

The 3786063 commit:

perf kvm: Rename perf_kvm to perf_kvm_stat

Moved the file_name from inside a local struct var that initialized some
of its members, thus zero initializing the not explicitely initialized
variables, one of which was 'file_name', to a standalone local variable,
but forgot to initialize it explicitely to NULL, so it then got some
undefined value, causing a segfault in strdup when it wasn't, by luck,
zero.

Fix it by explicitely initializing it to NULL.

Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Cc: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-qo2jevp1bdcnh8khzdazs17s@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/builtin-kvm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index ca3f80e..37a769d 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -973,8 +973,7 @@ __cmd_buildid_list(const char *file_name, int argc, const char **argv)

int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
{
- const char *file_name;
-
+ const char *file_name = NULL;
const struct option kvm_options[] = {
OPT_STRING('i', "input", &file_name, "file",
"Input file name"),
--
1.8.1.1.361.gec3ae6e

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/