perf probe: Fix to add NULL check for strndup
authorMasami Hiramatsu <mhiramat@kernel.org>
Wed, 8 Jun 2016 09:29:21 +0000 (18:29 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 14 Jun 2016 12:29:54 +0000 (09:29 -0300)
Fix to add a NULL check for strndup when parsing probe trace command.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160608092920.3116.63319.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-event.c

index 74401a20106d1c4baf9ed495125ede61995835f4..7ae3dd10f147897f763ef84d233014ab5d2dfdef 100644 (file)
@@ -1603,6 +1603,10 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev)
        p = strchr(argv[1], ':');
        if (p) {
                tp->module = strndup(argv[1], p - argv[1]);
+               if (!tp->module) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
                p++;
        } else
                p = argv[1];