aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2006-01-08 04:02:33 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:13:51 -0500
commit6b9c7ed84837753a436415097063232422e29a35 (patch)
tree6ad59a7bebcec359e08b3a211701781db819450d /arch/sparc/kernel
parent6b34350f490b2c8508717541ec1fd2bbaadded94 (diff)
[PATCH] use ptrace_get_task_struct in various places
The ptrace_get_task_struct() helper that I added as part of the ptrace consolidation is useful in variety of places that currently opencode it. Switch them to the common helpers. Add a ptrace_traceme() helper that needs to be explicitly called, and simplify the ptrace_get_task_struct() interface. We don't need the request argument now, and we return the task_struct directly, using ERR_PTR() for error returns. It's a bit more code in the callers, but we have two sane routines that do one thing well now. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/ptrace.c35
1 files changed, 6 insertions, 29 deletions
diff --git a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
index 475c4c13462c..fc470c0e9dc6 100644
--- a/arch/sparc/kernel/ptrace.c
+++ b/arch/sparc/kernel/ptrace.c
@@ -286,40 +286,17 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
286 s, (int) request, (int) pid, addr, data, addr2); 286 s, (int) request, (int) pid, addr, data, addr2);
287 } 287 }
288#endif 288#endif
289 if (request == PTRACE_TRACEME) {
290 int my_ret;
291
292 /* are we already being traced? */
293 if (current->ptrace & PT_PTRACED) {
294 pt_error_return(regs, EPERM);
295 goto out;
296 }
297 my_ret = security_ptrace(current->parent, current);
298 if (my_ret) {
299 pt_error_return(regs, -my_ret);
300 goto out;
301 }
302 289
303 /* set the ptrace bit in the process flags. */ 290 if (request == PTRACE_TRACEME) {
304 current->ptrace |= PT_PTRACED; 291 ret = ptrace_traceme();
305 pt_succ_return(regs, 0); 292 pt_succ_return(regs, 0);
306 goto out; 293 goto out;
307 } 294 }
308#ifndef ALLOW_INIT_TRACING
309 if (pid == 1) {
310 /* Can't dork with init. */
311 pt_error_return(regs, EPERM);
312 goto out;
313 }
314#endif
315 read_lock(&tasklist_lock);
316 child = find_task_by_pid(pid);
317 if (child)
318 get_task_struct(child);
319 read_unlock(&tasklist_lock);
320 295
321 if (!child) { 296 child = ptrace_get_task_struct(pid);
322 pt_error_return(regs, ESRCH); 297 if (IS_ERR(child)) {
298 ret = PTR_ERR(child);
299 pt_error_return(regs, -ret);
323 goto out; 300 goto out;
324 } 301 }
325 302