[lkml]   [2019]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.14] perf machine: Guard against NULL in machine__exit()
From: Arnaldo Carvalho de Melo <>

commit 4a2233b194c77ae1ea8304cb7c00b551de4313f0 upstream.

A recent fix for 'perf trace' introduced a bug where
machine__exit(trace->host) could be called while trace->host was still
NULL, so make this more robust by guarding against NULL, just like
free() does.

The problem happens, for instance, when !root users try to run 'perf

[acme@jouet linux]$ trace
Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'

perf: Segmentation fault
Obtained 7 stack frames.
/lib64/ [0x7f43a1dd971f]
/lib64/ [0x7f43a1dc3509]
Segmentation fault (core dumped)
[acme@jouet linux]$

Cc: Adrian Hunter <>
Cc: Alexander Shishkin <>
Cc: Andrei Vagin <>
Cc: David Ahern <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Cc: Peter Zijlstra <>
Cc: Vasily Averin <>
Cc: Wang Nan <>
Fixes: 33974a414ce2 ("perf trace: Call machine__exit() at exit")
Signed-off-by: Arnaldo Carvalho de Melo <>
Signed-off-by: Tommi Rantala <>
tools/perf/util/machine.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 968fd0454e6b..d246080cd85e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -156,6 +156,9 @@ void machine__delete_threads(struct machine *machine)

void machine__exit(struct machine *machine)
+ if (machine == NULL)
+ return;
 \ /
  Last update: 2019-06-19 14:01    [W:0.028 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site