- device_control = device_object->control_handle;
- if (device_control != MEMORY_OBJECT_CONTROL_NULL) {
- /*
- * The VM object should already have been disconnected
- * from the pager at this point.
- * We still have to release the "memory object control"
- * handle.
- */
- assert(device_control->moc_object == VM_OBJECT_NULL);
- memory_object_control_deallocate(device_control);
- device_object->control_handle =
- MEMORY_OBJECT_CONTROL_NULL;
- }
+ device_control = device_object->dev_pgr_hdr.mo_control;
+ memory_object_destroy(device_control, 0);
+ } else if (ref_count == 0) {
+ /*
+ * No more references: free the pager.
+ */
+ DTRACE_VM2(device_pager_free,
+ device_pager_t, device_object,
+ unsigned int, device_object->ref_count);
+
+ device_pager_lock_destroy(device_object);