Skip to contentSkip to conversation

fix incorrect copy_from_user usage

PERF EVENTS Joe Korty 2 participants 2 messages Sep 28, 2010 – Oct 12, 2010

lore
Share & tools
lore

Joe Korty

author
#0 lore raw

perf events: repair incorrect use of copy_from_user

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

kernel/perf_event.c +1 -3
Index: 2.6.36-rc5/kernel/perf_event.c
===================================================================
@@ -2202,15 +2202,13 @@
 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)
#1 lore raw

[tip:perf/urgent] perf: Fix incorrect copy_from_user() usage

Commit-ID:  ad0cf3478de8677f720ee06393b3147819568d6a
Gitweb:     http://git.kernel.org/tip/ad0cf3478de8677f720ee06393b3147819568d6a
Author:     John Blackwood <[email protected]>
AuthorDate: Tue, 28 Sep 2010 18:03:11 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 12 Oct 2010 11:45:01 +0200

perf: Fix incorrect copy_from_user() usage

perf events: repair incorrect use of copy_from_user

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

LKML-Reference: <[email protected]>

---
 kernel/perf_event.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
kernel/perf_event.c +1 -3
index db5b560..b98bed3 100644
@@ -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)