From cb8617c1d4562a7569e73b60c9c0f2001e63abb1 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 5 Jan 2010 22:02:58 +0000 Subject: [PATCH] unmap_and_free_physical_pages(): Added missing check whether the page mapping is actually present. This would have resulted in page 0 being freed over and over again, if we hadn't also incorrectly tried to look up the page by the virtual instead of the physical address. So we were actually freeing random pages. Fortunately the virtual addresses are kernel addresses, so that the affected pages lay beyond 2 GB and probably weren't used at this point yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34912 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 94aa479001..af422d08ac 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -2880,8 +2880,9 @@ unmap_and_free_physical_pages(vm_translation_map* map, addr_t start, addr_t end) addr_t physicalAddress; uint32 flags; - if (map->ops->query(map, current, &physicalAddress, &flags) == B_OK) { - vm_page* page = vm_lookup_page(current / B_PAGE_SIZE); + if (map->ops->query(map, current, &physicalAddress, &flags) == B_OK + && (flags & PAGE_PRESENT) != 0) { + vm_page* page = vm_lookup_page(physicalAddress / B_PAGE_SIZE); if (page != NULL) vm_page_set_state(page, PAGE_STATE_FREE); }