Skip to content

Commit

Permalink
mm/mmu_notifier: fix mmget() assert in __mmu_interval_notifier_insert
Browse files Browse the repository at this point in the history
The comment talks about having to hold mmget() (which means mm_users), but
the actual check is on mm_count (which would be mmgrab()).

Given that MMU notifiers are torn down in mmput() -> __mmput() ->
exit_mmap() -> mmu_notifier_release(), I believe that the comment is
correct and the check should be on mm->mm_users.  Fix it up accordingly.

Fixes: 99cb252 ("mm/mmu_notifier: add an interval tree notifier")
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Christian König <[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
thejh authored and torvalds committed Oct 16, 2020
1 parent 295a173 commit c9682d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/mmu_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ static int __mmu_interval_notifier_insert(
return -EOVERFLOW;

/* Must call with a mmget() held */
if (WARN_ON(atomic_read(&mm->mm_count) <= 0))
if (WARN_ON(atomic_read(&mm->mm_users) <= 0))
return -EINVAL;

/* pairs with mmdrop in mmu_interval_notifier_remove() */
Expand Down

0 comments on commit c9682d1

Please sign in to comment.