diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 386acbcccb68..f28271dc29be 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1920,16 +1920,19 @@ vm_map_clean( OFF_TO_IDX(offset), OFF_TO_IDX(offset + size + PAGE_MASK), flags); - if (invalidate) { - /*vm_object_pip_wait(object, "objmcl");*/ - vm_object_page_remove(object, - OFF_TO_IDX(offset), - OFF_TO_IDX(offset + size + PAGE_MASK), - FALSE); - } VOP_UNLOCK(object->handle, 0, curthread); vm_object_deallocate(object); } + if (object && invalidate && + ((object->type == OBJT_VNODE) || + (object->type == OBJT_DEVICE))) { + vm_object_reference(object); + vm_object_page_remove(object, + OFF_TO_IDX(offset), + OFF_TO_IDX(offset + size + PAGE_MASK), + FALSE); + vm_object_deallocate(object); + } start += size; }