aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10/kernel
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-10-27 18:33:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:10 -0400
commit475a4b813816fe9af4cdf7833799036b679f46d0 (patch)
tree8147812d582934768f7425c415e14019901ff302 /arch/cris/arch-v10/kernel
parentaeebd3a3d9f5b67a254f04e6eac91a74c5e1065e (diff)
ptrace: cleanup arch_ptrace() on cris
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>
Diffstat (limited to 'arch/cris/arch-v10/kernel')
-rw-r--r--arch/cris/arch-v10/kernel/ptrace.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
index d411e024e05f..320065f3cbe5 100644
--- a/arch/cris/arch-v10/kernel/ptrace.c
+++ b/arch/cris/arch-v10/kernel/ptrace.c
@@ -80,6 +80,7 @@ long arch_ptrace(struct task_struct *child, long request,
80 unsigned long addr, unsigned long data) 80 unsigned long addr, unsigned long data)
81{ 81{
82 int ret; 82 int ret;
83 unsigned int regno = addr >> 2;
83 unsigned long __user *datap = (unsigned long __user *)data; 84 unsigned long __user *datap = (unsigned long __user *)data;
84 85
85 switch (request) { 86 switch (request) {
@@ -94,10 +95,10 @@ long arch_ptrace(struct task_struct *child, long request,
94 unsigned long tmp; 95 unsigned long tmp;
95 96
96 ret = -EIO; 97 ret = -EIO;
97 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 98 if ((addr & 3) || regno > PT_MAX)
98 break; 99 break;
99 100
100 tmp = get_reg(child, addr >> 2); 101 tmp = get_reg(child, regno);
101 ret = put_user(tmp, datap); 102 ret = put_user(tmp, datap);
102 break; 103 break;
103 } 104 }
@@ -111,19 +112,17 @@ long arch_ptrace(struct task_struct *child, long request,
111 /* Write the word at location address in the USER area. */ 112 /* Write the word at location address in the USER area. */
112 case PTRACE_POKEUSR: 113 case PTRACE_POKEUSR:
113 ret = -EIO; 114 ret = -EIO;
114 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 115 if ((addr & 3) || regno > PT_MAX)
115 break; 116 break;
116 117
117 addr >>= 2; 118 if (regno == PT_DCCR) {
118
119 if (addr == PT_DCCR) {
120 /* don't allow the tracing process to change stuff like 119 /* don't allow the tracing process to change stuff like
121 * interrupt enable, kernel/user bit, dma enables etc. 120 * interrupt enable, kernel/user bit, dma enables etc.
122 */ 121 */
123 data &= DCCR_MASK; 122 data &= DCCR_MASK;
124 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK; 123 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK;
125 } 124 }
126 if (put_reg(child, addr, data)) 125 if (put_reg(child, regno, data))
127 break; 126 break;
128 ret = 0; 127 ret = 0;
129 break; 128 break;
@@ -142,7 +141,7 @@ long arch_ptrace(struct task_struct *child, long request,
142 break; 141 break;
143 } 142 }
144 143
145 data += sizeof(unsigned long); 144 datap++;
146 } 145 }
147 146
148 break; 147 break;
@@ -166,7 +165,7 @@ long arch_ptrace(struct task_struct *child, long request,
166 } 165 }
167 166
168 put_reg(child, i, tmp); 167 put_reg(child, i, tmp);
169 data += sizeof(unsigned long); 168 datap++;
170 } 169 }
171 170
172 break; 171 break;