diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 523d43558d5f..a0da9bb40e32 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1328,9 +1328,11 @@ vm_page_next(vm_page_t m) vm_page_t next; VM_OBJECT_ASSERT_LOCKED(m->object); - if ((next = TAILQ_NEXT(m, listq)) != NULL && - next->pindex != m->pindex + 1) - next = NULL; + if ((next = TAILQ_NEXT(m, listq)) != NULL) { + MPASS(next->object == m->object); + if (next->pindex != m->pindex + 1) + next = NULL; + } return (next); } @@ -1346,9 +1348,11 @@ vm_page_prev(vm_page_t m) vm_page_t prev; VM_OBJECT_ASSERT_LOCKED(m->object); - if ((prev = TAILQ_PREV(m, pglist, listq)) != NULL && - prev->pindex != m->pindex - 1) - prev = NULL; + if ((prev = TAILQ_PREV(m, pglist, listq)) != NULL) { + MPASS(prev->object == m->object); + if (prev->pindex != m->pindex - 1) + prev = NULL; + } return (prev); }