Skip to contentSkip to conversation

perf script: Fix a NULL pointer dereference

PATCH In review Namhyung Kim 2 participants 2 messages Aug 14, 2012 – Aug 21, 2012 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf script: Fix a NULL pointer dereference

From: Namhyung Kim <[email protected]>

If 'perf script --gen-script' was called with a perf.data which contains no tracepoint event, it'd segfault due to NULL pevent pointer. Fix it.

---
 tools/perf/util/trace-event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/trace-event-parse.c +1 -1
index 4cb7f3831f78..a5a554efeb50 100644
@@ -293,7 +293,7 @@ struct event_format *trace_find_next_event(struct pevent *pevent,
 {
 	static int idx;
 
-	if (!pevent->events)
+	if (!pevent || !pevent->events)
 		return NULL;
 
 	if (!event) {
Signature · 1 line
1.7.11.2
#1 lore raw
Commit-ID:  d0d3913895e5b50623bd4dafd876e41c1169031d
Gitweb:     http://git.kernel.org/tip/d0d3913895e5b50623bd4dafd876e41c1169031d
Author:     Namhyung Kim <[email protected]>
AuthorDate: Tue, 14 Aug 2012 10:57:03 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 14 Aug 2012 10:36:30 -0300

perf script: Fix a NULL pointer dereference

If 'perf script --gen-script' was called with a perf.data which contains no tracepoint event, it'd segfault due to NULL pevent pointer. Fix it.

---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +1 -1
index 4cb7f38..a5a554e 100644
@@ -293,7 +293,7 @@ struct event_format *trace_find_next_event(struct pevent *pevent,
 {
 	static int idx;
 
-	if (!pevent->events)
+	if (!pevent || !pevent->events)
 		return NULL;
 
 	if (!event) {