parisc: optimize variable initialization in do_page_fault
The attached change defers the initialization of the variables tsk, mm and flags until they are needed. As a result, the code won't crash if a kernel probe is done with a corrupt context and the code will be better optimized. Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
committed by
Helge Deller
parent
59b33f148c
commit
2d8b22de6e
@@ -171,20 +171,25 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
|
|||||||
unsigned long address)
|
unsigned long address)
|
||||||
{
|
{
|
||||||
struct vm_area_struct *vma, *prev_vma;
|
struct vm_area_struct *vma, *prev_vma;
|
||||||
struct task_struct *tsk = current;
|
struct task_struct *tsk;
|
||||||
struct mm_struct *mm = tsk->mm;
|
struct mm_struct *mm;
|
||||||
unsigned long acc_type;
|
unsigned long acc_type;
|
||||||
int fault;
|
int fault;
|
||||||
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
|
unsigned int flags;
|
||||||
|
|
||||||
if (in_atomic() || !mm)
|
if (in_atomic())
|
||||||
goto no_context;
|
goto no_context;
|
||||||
|
|
||||||
|
tsk = current;
|
||||||
|
mm = tsk->mm;
|
||||||
|
if (!mm)
|
||||||
|
goto no_context;
|
||||||
|
|
||||||
|
flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
|
||||||
if (user_mode(regs))
|
if (user_mode(regs))
|
||||||
flags |= FAULT_FLAG_USER;
|
flags |= FAULT_FLAG_USER;
|
||||||
|
|
||||||
acc_type = parisc_acctyp(code, regs->iir);
|
acc_type = parisc_acctyp(code, regs->iir);
|
||||||
|
|
||||||
if (acc_type & VM_WRITE)
|
if (acc_type & VM_WRITE)
|
||||||
flags |= FAULT_FLAG_WRITE;
|
flags |= FAULT_FLAG_WRITE;
|
||||||
retry:
|
retry:
|
||||||
|
Reference in New Issue
Block a user