]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ptrace: cleanup arch_ptrace() on cris
authorNamhyung Kim <namhyung@gmail.com>
Wed, 27 Oct 2010 22:33:51 +0000 (15:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Oct 2010 01:03:10 +0000 (18:03 -0700)
Use new 'regno' variable in order to remove redandunt expression and
remove checking @addr less than 0 because @addr is now unsigned.  Also
update 'datap' on PTRACE_GET/SETREGS to fix a bug on arch-v10.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/cris/arch-v10/kernel/ptrace.c
arch/cris/arch-v32/kernel/ptrace.c

index d411e024e05f2445c4f6968cf8a6a3e0f922e398..320065f3cbe5d63ededd695fc2a23412cf033a07 100644 (file)
@@ -80,6 +80,7 @@ long arch_ptrace(struct task_struct *child, long request,
                 unsigned long addr, unsigned long data)
 {
        int ret;
+       unsigned int regno = addr >> 2;
        unsigned long __user *datap = (unsigned long __user *)data;
 
        switch (request) {
@@ -94,10 +95,10 @@ long arch_ptrace(struct task_struct *child, long request,
                        unsigned long tmp;
 
                        ret = -EIO;
-                       if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)
+                       if ((addr & 3) || regno > PT_MAX)
                                break;
 
-                       tmp = get_reg(child, addr >> 2);
+                       tmp = get_reg(child, regno);
                        ret = put_user(tmp, datap);
                        break;
                }
@@ -111,19 +112,17 @@ long arch_ptrace(struct task_struct *child, long request,
                /* Write the word at location address in the USER area. */
                case PTRACE_POKEUSR:
                        ret = -EIO;
-                       if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)
+                       if ((addr & 3) || regno > PT_MAX)
                                break;
 
-                       addr >>= 2;
-
-                       if (addr == PT_DCCR) {
+                       if (regno == PT_DCCR) {
                                /* don't allow the tracing process to change stuff like
                                 * interrupt enable, kernel/user bit, dma enables etc.
                                 */
                                data &= DCCR_MASK;
                                data |= get_reg(child, PT_DCCR) & ~DCCR_MASK;
                        }
-                       if (put_reg(child, addr, data))
+                       if (put_reg(child, regno, data))
                                break;
                        ret = 0;
                        break;
@@ -142,7 +141,7 @@ long arch_ptrace(struct task_struct *child, long request,
                                        break;
                                }
                                
-                               data += sizeof(unsigned long);
+                               datap++;
                        }
 
                        break;
@@ -166,7 +165,7 @@ long arch_ptrace(struct task_struct *child, long request,
                                }
                                
                                put_reg(child, i, tmp);
-                               data += sizeof(unsigned long);
+                               datap++;
                        }
                        
                        break;
index 3e058a1217535d6047f27d709206004061501a15..511ece94a574a7b6ae2538774923e3d8e760140f 100644 (file)
@@ -130,6 +130,7 @@ long arch_ptrace(struct task_struct *child, long request,
                 unsigned long addr, unsigned long data)
 {
        int ret;
+       unsigned int regno = addr >> 2;
        unsigned long __user *datap = (unsigned long __user *)data;
 
        switch (request) {
@@ -164,10 +165,10 @@ long arch_ptrace(struct task_struct *child, long request,
                        unsigned long tmp;
 
                        ret = -EIO;
-                       if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)
+                       if ((addr & 3) || regno > PT_MAX)
                                break;
 
-                       tmp = get_reg(child, addr >> 2);
+                       tmp = get_reg(child, regno);
                        ret = put_user(tmp, datap);
                        break;
                }
@@ -181,19 +182,17 @@ long arch_ptrace(struct task_struct *child, long request,
                /* Write the word at location address in the USER area. */
                case PTRACE_POKEUSR:
                        ret = -EIO;
-                       if ((addr & 3) || addr < 0 || addr > PT_MAX << 2)
+                       if ((addr & 3) || regno > PT_MAX)
                                break;
 
-                       addr >>= 2;
-
-                       if (addr == PT_CCS) {
+                       if (regno == PT_CCS) {
                                /* don't allow the tracing process to change stuff like
                                 * interrupt enable, kernel/user bit, dma enables etc.
                                 */
                                data &= CCS_MASK;
                                data |= get_reg(child, PT_CCS) & ~CCS_MASK;
                        }
-                       if (put_reg(child, addr, data))
+                       if (put_reg(child, regno, data))
                                break;
                        ret = 0;
                        break;