mm/hmm.c:hmm_do_fault(): suppress sparse warning

mm/hmm.c:673 hmm_do_fault() error: we previously assumed 'hmm_vma_walk->locked' could be null (see line 654)

Stanislav says this can't happen.  Waste a few cycles to make the warning
go away.

[akpm@linux-foundation.org: WARN_ON_ONCE() if the handler didn't set ->locked, per Stanislav]
  Link: https://lore.kernel.org/anu1N-DOnQwxO1kF@skinsburskii
Fixes: 1211708312 ("mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/202608101053.PhnVUM4u-lkp@intel.com
Cc: Stanislav Kinsburskii <skinsburskii@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Andrew Morton 2026-08-10 13:16:37 -07:00
parent a1b114b4ce
commit 556147fc27

View File

@ -670,7 +670,10 @@ static int hmm_do_fault(struct mm_struct *mm,
ret = handle_mm_fault(vma, addr, fault_flags, NULL);
if (ret & (VM_FAULT_COMPLETED | VM_FAULT_RETRY)) {
*hmm_vma_walk->locked = false;
if (hmm_vma_walk->locked) /* needed by sparse */
*hmm_vma_walk->locked = false;
else
WARN_ON_ONCE(1); /* broken fault handler */
return HMM_FAULT_UNLOCKED;
}