Skip to content

Commit

Permalink
perf: Fix incorrect copy_from_user() usage
Browse files Browse the repository at this point in the history
perf events: repair incorrect use of copy_from_user

This makes the perf_event_period() return 0 instead of
-EFAULT on success.

Signed-off-by: John Blackwood<[email protected]>
Signed-off-by: Joe Korty <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
John Blackwood authored and Ingo Molnar committed Oct 12, 2010
1 parent 29979aa commit ad0cf34
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2202,15 +2202,13 @@ static void perf_event_for_each(struct perf_event *event,
static int perf_event_period(struct perf_event *event, u64 __user *arg)
{
struct perf_event_context *ctx = event->ctx;
unsigned long size;
int ret = 0;
u64 value;

if (!event->attr.sample_period)
return -EINVAL;

size = copy_from_user(&value, arg, sizeof(value));
if (size != sizeof(value))
if (copy_from_user(&value, arg, sizeof(value)))
return -EFAULT;

if (!value)
Expand Down

0 comments on commit ad0cf34

Please sign in to comment.