From: Arnaldo Carvalho de Melo Date: Thu, 26 Feb 2015 14:47:18 +0000 (-0300) Subject: perf probe: Handle strdup() failure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=38ae502b1df196f712f6f5d3609afc36337b330b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git perf probe: Handle strdup() failure We could end up returning 0 (Ok) with a NULL raw_path. Fix it. Acked-by: Masami Hiramatsu Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Naohiro Aota Link: http://lkml.kernel.org/n/tip-l0kcbcg5f4nnzqt01cv42vec@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 4a93bf433344..9526cf37682e 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -533,7 +533,7 @@ static int get_real_path(const char *raw_path, const char *comp_dir, else { if (access(raw_path, R_OK) == 0) { *new_path = strdup(raw_path); - return 0; + return *new_path ? 0 : -ENOMEM; } else return -errno; }