diff options
author | Stephane Eranian <eranian@google.com> | 2010-10-04 12:00:02 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-04 12:47:20 +0200 |
commit | 540804b5c52065a87d826f7714b18a3ec0b269f9 (patch) | |
tree | 71144b372d615c9c188860f9eaea062bdb8cb1c5 /kernel/perf_event.c | |
parent | d6dad199a10423ce37b8bfec1f055c380dc4a3d5 (diff) | |
download | linux-540804b5c52065a87d826f7714b18a3ec0b269f9.tar.bz2 |
perf_events: Fix invalid pointer when pid is invalid
This patch fixes an error in perf_event_open() when the pid
provided by the user is invalid. find_lively_task_by_vpid()
does not return NULL on error but an error code. Without the
fix the error code was silently passed to find_get_context()
which would eventually cause a invalid pointer dereference.
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: paulus@samba.org
Cc: davem@davemloft.net
Cc: fweisbec@gmail.com
Cc: perfmon2-devel@lists.sf.net
Cc: eranian@gmail.com
Cc: robert.richter@amd.com
LKML-Reference: <4ca9a5d1.e8e9d80a.3dbb.ffff8f2e@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r-- | kernel/perf_event.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index c16158c77dfd..64507eaa2d9e 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c @@ -5616,8 +5616,13 @@ SYSCALL_DEFINE5(perf_event_open, } } - if (pid != -1) + if (pid != -1) { task = find_lively_task_by_vpid(pid); + if (IS_ERR(task)) { + err = PTR_ERR(task); + goto err_group_fd; + } + } /* * Get the target context (task or percpu): |