Skip to content

Commit

Permalink
perf_counter: Fix perf_output_copy() WARN to account for overflow
Browse files Browse the repository at this point in the history
The simple reservation test in perf_output_copy() failed to take
unsigned int overflow into account, fix this.

[ Impact: fix false positive warning with more than 4GB of profiling data ]

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 15, 2009
1 parent a026dfe commit 53020fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,11 @@ static void perf_output_copy(struct perf_output_handle *handle,

handle->offset = offset;

WARN_ON_ONCE(handle->offset > handle->head);
/*
* Check we didn't copy past our reservation window, taking the
* possible unsigned int wrap into account.
*/
WARN_ON_ONCE(((int)(handle->head - handle->offset)) < 0);
}

#define perf_output_put(handle, x) \
Expand Down

0 comments on commit 53020fe

Please sign in to comment.