Skip to content

Commit 61cfce3

Browse files
torvaldsgregkh
authored andcommitted
x86: mm: move mmap_sem unlock from mm_fault_error() to caller
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>
1 parent 299f459 commit 61cfce3

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

‎arch/x86/mm/fault.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
844844
unsigned int fault)
845845
{
846846
struct task_struct *tsk = current;
847-
struct mm_struct *mm = tsk->mm;
848847
int code = BUS_ADRERR;
849848

850-
up_read(&mm->mmap_sem);
851-
852849
/* Kernel mode? Handle exceptions or die: */
853850
if (!(error_code & PF_USER)) {
854851
no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
@@ -879,22 +876,18 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
879876
unsigned long address, unsigned int fault)
880877
{
881878
if (fatal_signal_pending(current) && !(error_code & PF_USER)) {
882-
up_read(&current->mm->mmap_sem);
883879
no_context(regs, error_code, address, 0, 0);
884880
return;
885881
}
886882

887883
if (fault & VM_FAULT_OOM) {
888884
/* Kernel mode? Handle exceptions or die: */
889885
if (!(error_code & PF_USER)) {
890-
up_read(&current->mm->mmap_sem);
891886
no_context(regs, error_code, address,
892887
SIGSEGV, SEGV_MAPERR);
893888
return;
894889
}
895890

896-
up_read(&current->mm->mmap_sem);
897-
898891
/*
899892
* We ran out of memory, call the OOM killer, and return the
900893
* userspace (which will retry the fault, or kill us if we got
@@ -1249,6 +1242,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
12491242
return;
12501243

12511244
if (unlikely(fault & VM_FAULT_ERROR)) {
1245+
up_read(&mm->mmap_sem);
12521246
mm_fault_error(regs, error_code, address, fault);
12531247
return;
12541248
}

0 commit comments

Comments
 (0)