Loading...
iokit/Kernel/IOBufferMemoryDescriptor.cpp xnu-4570.61.1 xnu-3248.30.4
--- xnu/xnu-4570.61.1/iokit/Kernel/IOBufferMemoryDescriptor.cpp
+++ xnu/xnu-3248.30.4/iokit/Kernel/IOBufferMemoryDescriptor.cpp
@@ -66,8 +66,7 @@
 {
     kInternalFlagPhysical      = 0x00000001,
     kInternalFlagPageSized     = 0x00000002,
-    kInternalFlagPageAllocated = 0x00000004,
-    kInternalFlagInit          = 0x00000008
+    kInternalFlagPageAllocated = 0x00000004
 };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -290,11 +289,6 @@
 				inTask, iomdOptions, /* System mapper */ 0))
 	return false;
 
-    _internalFlags |= kInternalFlagInit;
-#if IOTRACKING
-    if (!(options & kIOMemoryPageable))	trackingAccumSize(capacity);
-#endif /* IOTRACKING */
-
     // give any system mapper the allocation params
     if (kIOReturnSuccess != dmaCommandOperation(kIOMDAddDMAMapSpec, 
     						&mapSpec, sizeof(mapSpec)))
@@ -494,26 +488,19 @@
 	    map->release();
     }
 
-    if ((options & kIOMemoryPageable)
-        || (kInternalFlagPageSized & internalFlags)) size = round_page(size);
-
-#if IOTRACKING
-    if (!(options & kIOMemoryPageable)
-	&& buffer
-	&& (kInternalFlagInit & _internalFlags)) trackingAccumSize(-size);
-#endif /* IOTRACKING */
-
     /* super::free may unwire - deallocate buffer afterwards */
     super::free();
 
     if (options & kIOMemoryPageable)
     {
 #if IOALLOCDEBUG
-	OSAddAtomicLong(-size, &debug_iomallocpageable_size);
+	OSAddAtomicLong(-(round_page(size)), &debug_iomallocpageable_size);
 #endif
     }
     else if (buffer)
     {
+	if (kInternalFlagPageSized & internalFlags) size = round_page(size);
+
         if (kInternalFlagPhysical & internalFlags)
         {
             IOKernelFreePhysical((mach_vm_address_t) buffer, size);
@@ -639,9 +626,6 @@
 IOBufferMemoryDescriptor::getBytesNoCopy(vm_size_t start, vm_size_t withLength)
 {
     IOVirtualAddress address;
-
-    if ((start + withLength) < start) return 0;
-
     if (kIOMemoryTypePhysical64 == (_flags & kIOMemoryTypeMask))
 	address = (IOVirtualAddress) _buffer;
     else