lkml.org 
[lkml]   [2013]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf evsel: fix NULL pointer deference when evsel->counts is NULL
Date
From: Colin Ian King <colin.king@canonical.com>

__perf_evsel__read_on_cpu() only bails out with -ENOMEM if
evsel->counts is NULL and perf_evsel__alloc_counts() has returned
an error. If perf_evsel__alloc_counts() does not return an error
we get an NULL pointer deference on evsel->counts->cpu[cpu]
if evsel->counts is NULL.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
tools/perf/util/evsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1b16dd1..93acd06 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -640,7 +640,7 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
if (FD(evsel, cpu, thread) < 0)
return -EINVAL;

- if (evsel->counts == NULL && perf_evsel__alloc_counts(evsel, cpu + 1) < 0)
+ if (evsel->counts == NULL || perf_evsel__alloc_counts(evsel, cpu + 1) < 0)
return -ENOMEM;

if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0)
--
1.8.0


\
 
 \ /
  Last update: 2013-01-19 18:21    [W:0.069 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site