Skip to content

Commit

Permalink
x86: mm: move mmap_sem unlock from mm_fault_error() to caller
Browse files Browse the repository at this point in the history
commit 7fb08ec upstream.

This replaces four copies in various stages of mm_fault_error() handling
with just a single one.  It will also allow for more natural placement
of the unlocking after some further cleanup.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
torvalds authored and gregkh committed Apr 29, 2015
1 parent 1f74b26 commit 2d892c7
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
unsigned int fault)
{
struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
int code = BUS_ADRERR;

up_read(&mm->mmap_sem);

/* Kernel mode? Handle exceptions or die: */
if (!(error_code & PF_USER)) {
no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
Expand Down Expand Up @@ -847,22 +844,18 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
unsigned long address, unsigned int fault)
{
if (fatal_signal_pending(current) && !(error_code & PF_USER)) {
up_read(&current->mm->mmap_sem);
no_context(regs, error_code, address, 0, 0);
return;
}

if (fault & VM_FAULT_OOM) {
/* Kernel mode? Handle exceptions or die: */
if (!(error_code & PF_USER)) {
up_read(&current->mm->mmap_sem);
no_context(regs, error_code, address,
SIGSEGV, SEGV_MAPERR);
return;
}

up_read(&current->mm->mmap_sem);

/*
* We ran out of memory, call the OOM killer, and return the
* userspace (which will retry the fault, or kill us if we got
Expand Down Expand Up @@ -1195,6 +1188,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
return;

if (unlikely(fault & VM_FAULT_ERROR)) {
up_read(&mm->mmap_sem);
mm_fault_error(regs, error_code, address, fault);
return;
}
Expand Down

0 comments on commit 2d892c7

Please sign in to comment.