Author: cgutman
Date: Fri Sep 5 14:51:18 2008
New Revision: 35964
URL:
http://svn.reactos.org/svn/reactos?rev=35964&view=rev
Log:
- Handle AllocatedResources and AllocatedResourcesTranslated separately
- Fix a memory leak
- Fix a handle leak
Modified:
branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c
branches/aicom-network-fixes/drivers/network/ndis/ndis/protocol.c
Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Fri Sep
5 14:51:18 2008
@@ -1293,8 +1293,7 @@
* NdisMQueryAdapterResources.
*/
- if (Stack->Parameters.StartDevice.AllocatedResources != NULL &&
- Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
+ if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
{
ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
PartialResourceList.Count;
@@ -1310,24 +1309,31 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
+ RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
+ Stack->Parameters.StartDevice.AllocatedResources,
+ ResourceListSize);
+ }
+
+ if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
+ {
+ ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
+ PartialResourceList.Count;
+ ResourceListSize =
+ FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
+ PartialDescriptors[ResourceCount]);
+
Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
ExAllocatePool(PagedPool, ResourceListSize);
if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
{
- ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
- Adapter->NdisMiniportBlock.AllocatedResources = NULL;
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return STATUS_INSUFFICIENT_RESOURCES;
}
- RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
- Stack->Parameters.StartDevice.AllocatedResources,
- ResourceListSize);
-
RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
ResourceListSize);
- }
+ }
/*
* Store the Bus Type, Bus Number and Slot information. It's used by
Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/ndis/ndis/protocol.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Fri Sep
5 14:51:18 2008
@@ -805,10 +805,11 @@
NtStatus = ZwQueryValueKey(DriverKeyHandle, &ValueName,
KeyValuePartialInformation, KeyInformation,
sizeof(KEY_VALUE_PARTIAL_INFORMATION) + ResultLength, &ResultLength);
+ ZwClose(DriverKeyHandle);
+
if(!NT_SUCCESS(NtStatus))
{
NDIS_DbgPrint(MIN_TRACE, ("Unable to query the Bind value\n"));
- ZwClose(DriverKeyHandle);
ExFreePool(KeyInformation);
ExFreePool(Protocol);
*Status = NDIS_STATUS_FAILURE;
@@ -893,7 +894,8 @@
*/
}
- *Status = NDIS_STATUS_SUCCESS;
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_SUCCESS;
}