From: Masami Hiramatsu Date: Wed, 8 Jun 2016 09:29:21 +0000 (+0900) Subject: perf probe: Fix to add NULL check for strndup X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=844faa4bcddc5d321311003ea3af9d808371c48e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git perf probe: Fix to add NULL check for strndup Fix to add a NULL check for strndup when parsing probe trace command. Signed-off-by: Masami Hiramatsu Cc: Ananth N Mavinakayanahalli Cc: Brendan Gregg Cc: Hemant Kumar Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20160608092920.3116.63319.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo --- 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];