[PATCH 03/19] perf probe: Fix to add NULL check for strndup

From: Arnaldo Carvalho de Melo
Date: Wed Jun 15 2016 - 14:15:57 EST


From: Masami Hiramatsu <mhiramat@xxxxxxxxxx>

Fix to add a NULL check for strndup when parsing probe trace command.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxxxxxxxxxx>
Cc: Brendan Gregg <brendan.d.gregg@xxxxxxxxx>
Cc: Hemant Kumar <hemant@xxxxxxxxxxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Link: 20160608092920.3116.63319.stgit@devbox">http://lkml.kernel.org/r/20160608092920.3116.63319.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/probe-event.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 74401a20106d..7ae3dd10f147 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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];
--
2.5.5