ptrace: cleanup arch_ptrace() on um

Remove unnecessary castings using void pointer and fix copy_to_user()
return value. Also add missing __user markup on the argument of
arch_ptrctl().

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Namhyung Kim 2010-10-27 15:34:04 -07:00 committed by Linus Torvalds
parent 8c0acac367
commit 0a3d763f1a
2 changed files with 11 additions and 14 deletions

View file

@ -47,6 +47,7 @@ long arch_ptrace(struct task_struct *child, long request,
{ {
int i, ret; int i, ret;
unsigned long __user *p = (void __user *)data; unsigned long __user *p = (void __user *)data;
void __user *vp = p;
switch (request) { switch (request) {
/* read word at location addr. */ /* read word at location addr. */
@ -108,24 +109,20 @@ long arch_ptrace(struct task_struct *child, long request,
#endif #endif
#ifdef PTRACE_GETFPREGS #ifdef PTRACE_GETFPREGS
case PTRACE_GETFPREGS: /* Get the child FPU state. */ case PTRACE_GETFPREGS: /* Get the child FPU state. */
ret = get_fpregs((struct user_i387_struct __user *) data, ret = get_fpregs(vp, child);
child);
break; break;
#endif #endif
#ifdef PTRACE_SETFPREGS #ifdef PTRACE_SETFPREGS
case PTRACE_SETFPREGS: /* Set the child FPU state. */ case PTRACE_SETFPREGS: /* Set the child FPU state. */
ret = set_fpregs((struct user_i387_struct __user *) data, ret = set_fpregs(vp, child);
child);
break; break;
#endif #endif
case PTRACE_GET_THREAD_AREA: case PTRACE_GET_THREAD_AREA:
ret = ptrace_get_thread_area(child, addr, ret = ptrace_get_thread_area(child, addr, vp);
(struct user_desc __user *) data);
break; break;
case PTRACE_SET_THREAD_AREA: case PTRACE_SET_THREAD_AREA:
ret = ptrace_set_thread_area(child, addr, ret = ptrace_set_thread_area(child, addr, datavp);
(struct user_desc __user *) data);
break; break;
case PTRACE_FAULTINFO: { case PTRACE_FAULTINFO: {
@ -135,7 +132,8 @@ long arch_ptrace(struct task_struct *child, long request,
* On i386, ptrace_faultinfo is smaller! * On i386, ptrace_faultinfo is smaller!
*/ */
ret = copy_to_user(p, &child->thread.arch.faultinfo, ret = copy_to_user(p, &child->thread.arch.faultinfo,
sizeof(struct ptrace_faultinfo)); sizeof(struct ptrace_faultinfo)) ?
-EIO : 0;
break; break;
} }
@ -159,7 +157,7 @@ long arch_ptrace(struct task_struct *child, long request,
#ifdef PTRACE_ARCH_PRCTL #ifdef PTRACE_ARCH_PRCTL
case PTRACE_ARCH_PRCTL: case PTRACE_ARCH_PRCTL:
/* XXX Calls ptrace on the host - needs some SMP thinking */ /* XXX Calls ptrace on the host - needs some SMP thinking */
ret = arch_prctl(child, data, (void *) addr); ret = arch_prctl(child, data, (void __user *) addr);
break; break;
#endif #endif
default: default:

View file

@ -179,15 +179,14 @@ long subarch_ptrace(struct task_struct *child, long request,
unsigned long addr, unsigned long data) unsigned long addr, unsigned long data)
{ {
int ret = -EIO; int ret = -EIO;
void __user *datap = (void __user *) data;
switch (request) { switch (request) {
case PTRACE_GETFPXREGS: /* Get the child FPU state. */ case PTRACE_GETFPXREGS: /* Get the child FPU state. */
ret = get_fpregs((struct user_i387_struct __user *) data, ret = get_fpregs(datap, child);
child);
break; break;
case PTRACE_SETFPXREGS: /* Set the child FPU state. */ case PTRACE_SETFPXREGS: /* Set the child FPU state. */
ret = set_fpregs((struct user_i387_struct __user *) data, ret = set_fpregs(datap, child);
child);
break; break;
} }