[TCPIP]
authorThomas Faber <thomas.faber@reactos.org>
Wed, 10 Aug 2016 11:19:59 +0000 (11:19 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 10 Aug 2016 11:19:59 +0000 (11:19 +0000)
- Use pool tagging

svn path=/trunk/; revision=72184

reactos/drivers/network/tcpip/datalink/lan.c
reactos/drivers/network/tcpip/include/tags.h
reactos/drivers/network/tcpip/tcpip/iinfo.c
reactos/drivers/network/tcpip/tcpip/ninfo.c

index 1f33550..4cbbec9 100644 (file)
@@ -138,8 +138,9 @@ GetPacketTypeFromNdisPacket(PLAN_ADAPTER Adapter,
     ULONG BytesCopied;
     NDIS_STATUS Status;
     
-    HeaderBuffer = ExAllocatePool(NonPagedPool,
-                                  Adapter->HeaderSize);
+    HeaderBuffer = ExAllocatePoolWithTag(NonPagedPool,
+                                         Adapter->HeaderSize,
+                                         HEADER_TAG);
     if (!HeaderBuffer)
         return NDIS_STATUS_RESOURCES;
     
@@ -151,7 +152,7 @@ GetPacketTypeFromNdisPacket(PLAN_ADAPTER Adapter,
     if (BytesCopied != Adapter->HeaderSize)
     {
         /* Runt frame */
-        ExFreePool(HeaderBuffer);
+        ExFreePoolWithTag(HeaderBuffer, HEADER_TAG);
         TI_DbgPrint(DEBUG_DATALINK, ("Runt frame (size %d).\n", BytesCopied));
         return NDIS_STATUS_NOT_ACCEPTED;
     }
@@ -161,7 +162,7 @@ GetPacketTypeFromNdisPacket(PLAN_ADAPTER Adapter,
                                            BytesCopied,
                                            PacketType);
     
-    ExFreePool(HeaderBuffer);
+    ExFreePoolWithTag(HeaderBuffer, HEADER_TAG);
     
     return Status;
 }
@@ -607,7 +608,7 @@ BOOLEAN ReadIpConfiguration(PIP_INTERFACE Interface)
     }
     else
     {
-        KeyValueInfo = ExAllocatePool(PagedPool, sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 * sizeof(WCHAR));
+        KeyValueInfo = ExAllocatePoolWithTag(PagedPool, sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 * sizeof(WCHAR), KEY_VALUE_TAG);
         if (!KeyValueInfo)
         {
             ZwClose(ParameterHandle);
@@ -696,6 +697,7 @@ BOOLEAN ReadIpConfiguration(PIP_INTERFACE Interface)
             }
         }
         
+        ExFreePoolWithTag(KeyValueInfo, KEY_VALUE_TAG);
         ZwClose(ParameterHandle);
     }
     
@@ -823,7 +825,7 @@ VOID NTAPI ProtocolStatus(
     if (!Adapter->Context)
         return;
     
-    Context = ExAllocatePool(NonPagedPool, sizeof(RECONFIGURE_CONTEXT));
+    Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(RECONFIGURE_CONTEXT), CONTEXT_TAG);
     if (!Context)
         return;
     
@@ -836,7 +838,7 @@ VOID NTAPI ProtocolStatus(
 
             if (Adapter->State == LAN_STATE_STARTED)
             {
-                ExFreePool(Context);
+                ExFreePoolWithTag(Context, CONTEXT_TAG);
                 return;
             }
 
@@ -848,7 +850,7 @@ VOID NTAPI ProtocolStatus(
             
             if (Adapter->State == LAN_STATE_STOPPED)
             {
-                ExFreePool(Context);
+                ExFreePoolWithTag(Context, CONTEXT_TAG);
                 return;
             }
             
@@ -859,7 +861,7 @@ VOID NTAPI ProtocolStatus(
             Adapter->OldState = Adapter->State;
             Adapter->State = LAN_STATE_RESETTING;
             /* Nothing else to do here */
-            ExFreePool(Context);
+            ExFreePoolWithTag(Context, CONTEXT_TAG);
             return;
 
         case NDIS_STATUS_RESET_END:
@@ -869,13 +871,13 @@ VOID NTAPI ProtocolStatus(
 
         default:
             DbgPrint("Unhandled status: %x", GeneralStatus);
-            ExFreePool(Context);
+            ExFreePoolWithTag(Context, CONTEXT_TAG);
             return;
     }
 
     /* Queue the work item */
     if (!ChewCreate(ReconfigureAdapterWorker, Context))
-        ExFreePool(Context);
+        ExFreePoolWithTag(Context, CONTEXT_TAG);
 }
 
 VOID NTAPI ProtocolStatusComplete(NDIS_HANDLE NdisBindingContext)
@@ -1108,8 +1110,8 @@ static NTSTATUS ReadStringFromRegistry( HANDLE RegHandle,
     UnicodeString.MaximumLength = Information->DataLength;
 
     String->Buffer =
-       (PWCHAR)ExAllocatePool( NonPagedPool,
-                               UnicodeString.MaximumLength + sizeof(WCHAR) );
+       (PWCHAR)ExAllocatePoolWithTag( NonPagedPool,
+                               UnicodeString.MaximumLength + sizeof(WCHAR), REG_STR_TAG );
 
     if( !String->Buffer ) return STATUS_NO_MEMORY;
 
@@ -1135,9 +1137,9 @@ NTSTATUS NTAPI AppendUnicodeString(PUNICODE_STRING ResultFirst,
                                   BOOLEAN Deallocate) {
     NTSTATUS Status;
     UNICODE_STRING Ustr = *ResultFirst;
-    PWSTR new_string = ExAllocatePool
+    PWSTR new_string = ExAllocatePoolWithTag
         (PagedPool,
-         (ResultFirst->Length + Second->Length + sizeof(WCHAR)));
+         (ResultFirst->Length + Second->Length + sizeof(WCHAR)), TEMP_STRING_TAG);
     if( !new_string ) {
        return STATUS_NO_MEMORY;
     }
@@ -1150,7 +1152,7 @@ NTSTATUS NTAPI AppendUnicodeString(PUNICODE_STRING ResultFirst,
     new_string[ResultFirst->Length / sizeof(WCHAR)] = 0;
     Status = RtlCreateUnicodeString(ResultFirst,new_string) ?
        STATUS_SUCCESS : STATUS_NO_MEMORY;
-    ExFreePool(new_string);
+    ExFreePoolWithTag(new_string, TEMP_STRING_TAG);
     return Status;
 }
 
@@ -1213,7 +1215,7 @@ static NTSTATUS FindDeviceDescForAdapter( PUNICODE_STRING Name,
     NTSTATUS Status;
     ULONG i;
     KEY_BASIC_INFORMATION *Kbio =
-        ExAllocatePool(NonPagedPool, sizeof(KEY_BASIC_INFORMATION));
+        ExAllocatePoolWithTag(NonPagedPool, sizeof(KEY_BASIC_INFORMATION), KBIO_TAG);
     ULONG KbioLength = sizeof(KEY_BASIC_INFORMATION), ResultLength;
 
     RtlInitUnicodeString( DeviceDesc, NULL );
@@ -1228,7 +1230,7 @@ static NTSTATUS FindDeviceDescForAdapter( PUNICODE_STRING Name,
     if( !NT_SUCCESS(Status) ) {
         TI_DbgPrint(DEBUG_DATALINK,("Couldn't open Enum key %wZ: %x\n",
                                     &EnumKeyName, Status));
-        ExFreePool( Kbio );
+        ExFreePoolWithTag( Kbio, KBIO_TAG );
         return Status;
     }
 
@@ -1237,9 +1239,9 @@ static NTSTATUS FindDeviceDescForAdapter( PUNICODE_STRING Name,
                                  Kbio, KbioLength, &ResultLength );
 
         if( Status == STATUS_BUFFER_TOO_SMALL || Status == STATUS_BUFFER_OVERFLOW ) {
-            ExFreePool( Kbio );
+            ExFreePoolWithTag( Kbio, KBIO_TAG );
             KbioLength = ResultLength;
-            Kbio = ExAllocatePool( NonPagedPool, KbioLength );
+            Kbio = ExAllocatePoolWithTag( NonPagedPool, KbioLength, KBIO_TAG );
             if( !Kbio ) {
                 TI_DbgPrint(DEBUG_DATALINK,("Failed to allocate memory\n"));
                 ZwClose( EnumKey );
@@ -1252,7 +1254,7 @@ static NTSTATUS FindDeviceDescForAdapter( PUNICODE_STRING Name,
             if( !NT_SUCCESS(Status) ) {
                 TI_DbgPrint(DEBUG_DATALINK,("Couldn't enum key child %d\n", i));
                 ZwClose( EnumKey );
-                ExFreePool( Kbio );
+                ExFreePoolWithTag( Kbio, KBIO_TAG );
                 return Status;
             }
         }
@@ -1266,14 +1268,14 @@ static NTSTATUS FindDeviceDescForAdapter( PUNICODE_STRING Name,
                 ( &EnumKeyName, &TargetKeyName, Name, DeviceDesc );
             if( NT_SUCCESS(Status) ) {
                 ZwClose( EnumKey );
-                ExFreePool( Kbio );
+                ExFreePoolWithTag( Kbio, KBIO_TAG );
                 return Status;
             } else Status = STATUS_SUCCESS;
         }
     }
 
     ZwClose( EnumKey );
-    ExFreePool( Kbio );
+    ExFreePoolWithTag( Kbio, KBIO_TAG );
     return STATUS_UNSUCCESSFUL;
 }
 
index bd55276..15c0b90 100644 (file)
 #define OSK_SMALL_TAG 'SKSO'
 #define LAN_ADAPTER_TAG ' NAL'
 #define WQ_CONTEXT_TAG 'noCW'
+#define ROUTE_ENTRY_TAG 'erCT'
+#define OUT_DATA_TAG 'doCT'
+#define ARP_ENTRY_TAG 'raCT'
+#define KBIO_TAG 'ikCT'
+#define TEMP_STRING_TAG 'tsCT'
+#define CONTEXT_TAG 'xcCT'
+#define KEY_VALUE_TAG 'vkCT'
+#define HEADER_TAG 'rhCT'
+#define REG_STR_TAG 'srCT'
index 3a549f4..9ee74ac 100644 (file)
@@ -35,7 +35,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
                ("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n",
                 Interface, IF, ID.tei_entity, ID.tei_instance));
 
-    OutData = ExAllocatePool( NonPagedPool, FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1]));
+    OutData = ExAllocatePoolWithTag( NonPagedPool, FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1]), OUT_DATA_TAG );
 
     if( !OutData ) return TDI_NO_RESOURCES; /* Out of memory */
 
@@ -95,7 +95,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
                            ID.tei_entity, ID.tei_instance, Size));
 
     Status = InfoCopyOut( (PCHAR)OutData, Size, Buffer, BufferSize );
-    ExFreePool( OutData );
+    ExFreePoolWithTag( OutData, OUT_DATA_TAG );
 
     TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status));
 
@@ -113,14 +113,14 @@ TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID,
 
     if (MemSize != 0)
     {
-        ArpEntries = ExAllocatePool( NonPagedPool, MemSize );
+        ArpEntries = ExAllocatePoolWithTag( NonPagedPool, MemSize, ARP_ENTRY_TAG );
         if( !ArpEntries ) return STATUS_NO_MEMORY;
 
         NBCopyNeighbors( Interface, ArpEntries );
 
         Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize );
 
-        ExFreePool( ArpEntries );
+        ExFreePoolWithTag( ArpEntries, ARP_ENTRY_TAG );
     }
     else
     {
index bd9e7b9..182af70 100644 (file)
@@ -29,15 +29,15 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI
     if (RtCount == 0)
         return InfoCopyOut(NULL, 0, NULL, BufferSize);
 
-    RouteEntries = ExAllocatePool( NonPagedPool, Size );
+    RouteEntries = ExAllocatePoolWithTag( NonPagedPool, Size, ROUTE_ENTRY_TAG );
     RtCurrent = RouteEntries;
 
-    RCache = ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount );
+    RCache = ExAllocatePoolWithTag( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount, FIB_TAG );
     RCacheCur = RCache;
 
     if( !RCache || !RouteEntries ) {
-       if( RCache ) ExFreePool( RCache );
-       if( RouteEntries ) ExFreePool( RouteEntries );
+       if( RCache ) ExFreePoolWithTag( RCache, FIB_TAG );
+       if( RouteEntries ) ExFreePoolWithTag( RouteEntries, ROUTE_ENTRY_TAG );
        return TDI_NO_RESOURCES;
     }
 
@@ -87,8 +87,8 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI
 
     Status = InfoCopyOut( (PCHAR)RouteEntries, Size, Buffer, BufferSize );
 
-    ExFreePool( RouteEntries );
-    ExFreePool( RCache );
+    ExFreePoolWithTag( RouteEntries, ROUTE_ENTRY_TAG );
+    ExFreePoolWithTag( RCache, FIB_TAG );
 
     TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));
 
@@ -122,7 +122,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable(TDIEntityID ID,
         return TDI_INVALID_PARAMETER;
     }
 
-    IPEntry = ExAllocatePool(NonPagedPool, sizeof(IPADDR_ENTRY));
+    IPEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPADDR_ENTRY), IP_ADDRESS_TAG);
     if (!IPEntry)
     {
         TcpipReleaseSpinLock(&EntityListLock, OldIrql);
@@ -147,7 +147,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable(TDIEntityID ID,
     InfoCopyOut((PCHAR)IPEntry, sizeof(IPADDR_ENTRY),
                Buffer, BufferSize);
 
-    ExFreePool(IPEntry);
+    ExFreePoolWithTag(IPEntry, IP_ADDRESS_TAG);
 
     return TDI_SUCCESS;
 }