- Handle AllocatedResources and AllocatedResourcesTranslated separately

- Fix a memory leak
 - Fix a handle leak

svn path=/branches/aicom-network-fixes/; revision=35964
This commit is contained in:
Cameron Gutman 2008-09-05 19:51:18 +00:00
parent 16427a1482
commit 85672737e6
2 changed files with 19 additions and 11 deletions

View file

@ -1293,8 +1293,7 @@ NdisIPnPStartDevice(
* NdisMQueryAdapterResources. * NdisMQueryAdapterResources.
*/ */
if (Stack->Parameters.StartDevice.AllocatedResources != NULL && if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
{ {
ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0]. ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
PartialResourceList.Count; PartialResourceList.Count;
@ -1310,24 +1309,31 @@ NdisIPnPStartDevice(
return STATUS_INSUFFICIENT_RESOURCES; 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 = Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
ExAllocatePool(PagedPool, ResourceListSize); ExAllocatePool(PagedPool, ResourceListSize);
if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL) if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
{ {
ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
Adapter->NdisMiniportBlock.AllocatedResources = NULL;
ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock ); ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
Stack->Parameters.StartDevice.AllocatedResources,
ResourceListSize);
RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated, RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
Stack->Parameters.StartDevice.AllocatedResourcesTranslated, Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
ResourceListSize); ResourceListSize);
} }
/* /*
* Store the Bus Type, Bus Number and Slot information. It's used by * Store the Bus Type, Bus Number and Slot information. It's used by

View file

@ -805,10 +805,11 @@ NdisRegisterProtocol(
NtStatus = ZwQueryValueKey(DriverKeyHandle, &ValueName, KeyValuePartialInformation, KeyInformation, NtStatus = ZwQueryValueKey(DriverKeyHandle, &ValueName, KeyValuePartialInformation, KeyInformation,
sizeof(KEY_VALUE_PARTIAL_INFORMATION) + ResultLength, &ResultLength); sizeof(KEY_VALUE_PARTIAL_INFORMATION) + ResultLength, &ResultLength);
ZwClose(DriverKeyHandle);
if(!NT_SUCCESS(NtStatus)) if(!NT_SUCCESS(NtStatus))
{ {
NDIS_DbgPrint(MIN_TRACE, ("Unable to query the Bind value\n")); NDIS_DbgPrint(MIN_TRACE, ("Unable to query the Bind value\n"));
ZwClose(DriverKeyHandle);
ExFreePool(KeyInformation); ExFreePool(KeyInformation);
ExFreePool(Protocol); ExFreePool(Protocol);
*Status = NDIS_STATUS_FAILURE; *Status = NDIS_STATUS_FAILURE;
@ -893,7 +894,8 @@ NdisRegisterProtocol(
*/ */
} }
*Status = NDIS_STATUS_SUCCESS; ExFreePool(KeyInformation);
*Status = NDIS_STATUS_SUCCESS;
} }