Skip to content

Commit 2d8b22d

Browse files
danglin44hdeller
authored andcommitted
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 <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 59b33f1 commit 2d8b22d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/parisc/mm/fault.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,25 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
171171
unsigned long address)
172172
{
173173
struct vm_area_struct *vma, *prev_vma;
174-
struct task_struct *tsk = current;
175-
struct mm_struct *mm = tsk->mm;
174+
struct task_struct *tsk;
175+
struct mm_struct *mm;
176176
unsigned long acc_type;
177177
int fault;
178-
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
178+
unsigned int flags;
179179

180-
if (in_atomic() || !mm)
180+
if (in_atomic())
181181
goto no_context;
182182

183+
tsk = current;
184+
mm = tsk->mm;
185+
if (!mm)
186+
goto no_context;
187+
188+
flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
183189
if (user_mode(regs))
184190
flags |= FAULT_FLAG_USER;
185191

186192
acc_type = parisc_acctyp(code, regs->iir);
187-
188193
if (acc_type & VM_WRITE)
189194
flags |= FAULT_FLAG_WRITE;
190195
retry:

0 commit comments

Comments
 (0)