Skip to contentSkip to conversation

proc: copy_to_user() returns unsigned

PATCH In review Dan Carpenter 4 participants 4 messages Apr 6, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: copy_to_user() returns unsigned

copy_to_user() returns the number of bytes left to be copied.

This was a typo from: d82ef020cf31504c816803b1def94eb5ff173363 "proc: pagemap: Hold mmap_sem during page walk".

fs/proc/task_mmu.c +1 -1
index 0962739..bfb2773 100644
@@ -799,7 +799,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		start_vaddr = end;
 
 		len = min(count, PM_ENTRY_BYTES * pm.pos);
-		if (copy_to_user(buf, pm.buffer, len) < 0) {
+		if (copy_to_user(buf, pm.buffer, len)) {
 			ret = -EFAULT;
 			goto out_free;
 		}
Reviewed-by on v1 1/1
#1 lore raw

I got confused when I see the title of patch. That's because I understood copy_to_user returns unsigned. Please, change title to describe your patch.

[PATCH] proc : fix wrong usage of copy_to_user's return value.

Maybe you could name it well than me who is a not native English.

Quoted 6 lines · Dan Carpenter

copy_to_user() returns the number of bytes left to be copied.

This was a typo from: d82ef020cf31504c816803b1def94eb5ff173363 "proc: pagemap: Hold mmap_sem during page walk".

Signature · 2 lines
Kind regards,
Minchan Kim
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 12 lines

copy_to_user() returns the number of bytes left to be copied.

This was a typo from: d82ef020cf31504c816803b1def94eb5ff173363 "proc: pagemap: Hold mmap_sem during page walk".

fs/proc/task_mmu.c +0 -0
index 0962739..bfb2773 100644

fs/proc/task_mmu.c static ssize_t pagemap_read(struct file *file, char __user *buf, · line 805

Quoted 8 lines
fs/proc/task_mmu.c +1 -1
@@ -799,7 +799,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		start_vaddr = end;
 
 		len = min(count, PM_ENTRY_BYTES * pm.pos);
-		if (copy_to_user(buf, pm.buffer, len) < 0) {
+		if (copy_to_user(buf, pm.buffer, len)) {
 			ret = -EFAULT;
 			goto out_free;
 		}

However I don't think this patch is kernel-janitors material. it should be just merged mainline soon.

Acked-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter
Quoted 12 lines · Dan Carpenter

copy_to_user() returns the number of bytes left to be copied.

This was a typo from: d82ef020cf31504c816803b1def94eb5ff173363 "proc: pagemap: Hold mmap_sem during page walk".

fs/proc/task_mmu.c +0 -0
index 0962739..bfb2773 100644

fs/proc/task_mmu.c static ssize_t pagemap_read(struct file *file, char __user *buf, · line 805

Quoted 8 lines
fs/proc/task_mmu.c +1 -1
@@ -799,7 +799,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		start_vaddr = end;
 
 		len = min(count, PM_ENTRY_BYTES * pm.pos);
-		if (copy_to_user(buf, pm.buffer, len) < 0) {
+		if (copy_to_user(buf, pm.buffer, len)) {
 			ret = -EFAULT;
 			goto out_free;
 		}

Linus, please take this one too.

Signature · 1 line
http://selenic.com : development and support for Mercurial and Linux