From: Jann Horn Date: Fri, 16 Oct 2020 03:07:43 +0000 (-0700) Subject: mm/mmu_notifier: fix mmget() assert in __mmu_interval_notifier_insert X-Git-Tag: v5.15~2654^2~98 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9682d10271e1025ebfbb1675c7afffbef5c6856;p=platform%2Fkernel%2Flinux-starfive.git mm/mmu_notifier: fix mmget() assert in __mmu_interval_notifier_insert 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: 99cb252f5e68 ("mm/mmu_notifier: add an interval tree notifier") Signed-off-by: Jann Horn Signed-off-by: Andrew Morton Reviewed-by: Jason Gunthorpe Cc: John Hubbard Cc: Christoph Hellwig Cc: Christian König --- diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 4fc9181..5654dd1 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -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() */