perf: Fix incorrect copy_from_user() usage
authorJohn Blackwood <john.blackwood@ccur.com>
Tue, 28 Sep 2010 22:03:11 +0000 (18:03 -0400)
committerIngo Molnar <mingo@elte.hu>
Tue, 12 Oct 2010 09:45:01 +0000 (11:45 +0200)
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<john.blackwood@ccur.com>
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20100928220311.GA18145@tsunami.ccur.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/perf_event.c

index db5b56064687e453c0df1cc118b975ea047bdcae..b98bed3d8182685ffff2b840c0ff4809b4f65cb8 100644 (file)
@@ -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)