- Fix a memory leak
authorCameron Gutman <aicommander@gmail.com>
Tue, 30 Sep 2008 00:02:53 +0000 (00:02 +0000)
committerCameron Gutman <aicommander@gmail.com>
Tue, 30 Sep 2008 00:02:53 +0000 (00:02 +0000)
svn path=/branches/aicom-network-fixes/; revision=36592

drivers/network/ndis/ndis/config.c

index c369d7a..7205756 100644 (file)
@@ -479,6 +479,15 @@ NdisReadConfiguration(
         return;
     }
 
+    MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
+    if(!MiniportResource)
+    {
+       NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+       ExFreePool(KeyInformation);
+       *Status = NDIS_STATUS_RESOURCES;
+       return;
+    }
+
     switch(ParameterType)
     {
         case NdisParameterInteger:
@@ -516,8 +525,15 @@ NdisReadConfiguration(
                 ExFreePool(*ParameterValue);
                 *ParameterValue = NULL;
                 *Status = NDIS_STATUS_FAILURE;
-            } else
-                *Status = NDIS_STATUS_SUCCESS;
+                return;
+            }
+
+            MiniportResource->ResourceType = 0;
+            MiniportResource->Resource = *ParameterValue;
+            NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n", MiniportResource->Resource));
+            ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead, &MiniportResource->ListEntry, &ConfigurationContext->ResourceLock);
+
+            *Status = NDIS_STATUS_SUCCESS;
 
             return;
         }
@@ -556,18 +572,6 @@ NdisReadConfiguration(
                 return;
             }
 
-            MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
-            if(!MiniportResource)
-            {
-                NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
-                ExFreePool(RegData);
-                ExFreePool(KeyInformation);
-                ExFreePool(*ParameterValue);
-                *ParameterValue = NULL;
-                *Status = NDIS_STATUS_RESOURCES;
-                return;
-            }
-
             MiniportResource->ResourceType = 0;
             MiniportResource->Resource = *ParameterValue;
             NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n", MiniportResource->Resource));
@@ -605,17 +609,6 @@ NdisReadConfiguration(
                 return;
             }
 
-            MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
-            if(!MiniportResource)
-            {
-                NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
-                ExFreePool(KeyInformation);
-                ExFreePool(*ParameterValue);
-                *ParameterValue = NULL;
-                *Status = NDIS_STATUS_RESOURCES;
-                return;
-            }
-
             MiniportResource->ResourceType = 0;
             MiniportResource->Resource = *ParameterValue;
             NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n", MiniportResource->Resource));