[PARISC] Fix show_stack() when we can't kmalloc

show_stack() was calling kzalloc() to allocate a struct pt_regs.
This meant that *really* early stack dumps would cause a null pointer
dereference.  x86_64 allocates its pt_regs on the stack, so do the same.

Kyle actually committed this exact patch to CVS on
Wed Jul 26 14:32:39 2006 UTC, and never moved it across to git.
Bad Kyle.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
This commit is contained in:
Matthew Wilcox 2006-12-15 22:47:47 -07:00 committed by Kyle McMartin
parent e6fc0449be
commit 9f15c82686
1 changed files with 10 additions and 9 deletions

View File

@ -187,18 +187,19 @@ void show_stack(struct task_struct *task, unsigned long *s)
if (!task) { if (!task) {
unsigned long sp; unsigned long sp;
struct pt_regs *r;
HERE: HERE:
asm volatile ("copy %%r30, %0" : "=r"(sp)); asm volatile ("copy %%r30, %0" : "=r"(sp));
r = kzalloc(sizeof(struct pt_regs), GFP_KERNEL); {
if (!r) struct pt_regs r;
return;
r->iaoq[0] = (unsigned long)&&HERE; memset(&r, 0, sizeof(struct pt_regs));
r->gr[2] = (unsigned long)__builtin_return_address(0); r.iaoq[0] = (unsigned long)&&HERE;
r->gr[30] = sp; r.gr[2] = (unsigned long)__builtin_return_address(0);
unwind_frame_init(&info, current, r); r.gr[30] = sp;
kfree(r);
unwind_frame_init(&info, current, &r);
}
} else { } else {
unwind_frame_init_from_blocked_task(&info, task); unwind_frame_init_from_blocked_task(&info, task);
} }