mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
Get rid of one memory leak and two more ROS-only fields in LOGICAL_ADAPTER structure.
svn path=/trunk/; revision=17498
This commit is contained in:
parent
82af9fdaa8
commit
c905ca8a31
2 changed files with 17 additions and 56 deletions
|
@ -80,8 +80,6 @@ typedef struct _LOGICAL_ADAPTER
|
||||||
LIST_ENTRY ListEntry; /* Entry on global list */
|
LIST_ENTRY ListEntry; /* Entry on global list */
|
||||||
LIST_ENTRY MiniportListEntry; /* Entry on miniport driver list */
|
LIST_ENTRY MiniportListEntry; /* Entry on miniport driver list */
|
||||||
LIST_ENTRY ProtocolListHead; /* List of bound protocols */
|
LIST_ENTRY ProtocolListHead; /* List of bound protocols */
|
||||||
PVOID QueryBuffer; /* Buffer to use for queries */
|
|
||||||
ULONG QueryBufferLength; /* Length of QueryBuffer */
|
|
||||||
ULONG MediumHeaderSize; /* Size of medium header */
|
ULONG MediumHeaderSize; /* Size of medium header */
|
||||||
HARDWARE_ADDRESS Address; /* Hardware address of adapter */
|
HARDWARE_ADDRESS Address; /* Hardware address of adapter */
|
||||||
ULONG AddressLength; /* Length of hardware address */
|
ULONG AddressLength; /* Length of hardware address */
|
||||||
|
@ -128,6 +126,7 @@ MiniQueryInformation(
|
||||||
PLOGICAL_ADAPTER Adapter,
|
PLOGICAL_ADAPTER Adapter,
|
||||||
NDIS_OID Oid,
|
NDIS_OID Oid,
|
||||||
ULONG Size,
|
ULONG Size,
|
||||||
|
PVOID Buffer,
|
||||||
PULONG BytesWritten);
|
PULONG BytesWritten);
|
||||||
|
|
||||||
NDIS_STATUS
|
NDIS_STATUS
|
||||||
|
|
|
@ -548,13 +548,15 @@ MiniQueryInformation(
|
||||||
PLOGICAL_ADAPTER Adapter,
|
PLOGICAL_ADAPTER Adapter,
|
||||||
NDIS_OID Oid,
|
NDIS_OID Oid,
|
||||||
ULONG Size,
|
ULONG Size,
|
||||||
|
PVOID Buffer,
|
||||||
PULONG BytesWritten)
|
PULONG BytesWritten)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Queries a logical adapter for properties
|
* FUNCTION: Queries a logical adapter for properties
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* Adapter = Pointer to the logical adapter object to query
|
* Adapter = Pointer to the logical adapter object to query
|
||||||
* Oid = Specifies the Object ID to query for
|
* Oid = Specifies the Object ID to query for
|
||||||
* Size = If non-zero overrides the length in the adapter object
|
* Size = Size of the passed buffer
|
||||||
|
* Buffer = Buffer for the output
|
||||||
* BytesWritten = Address of buffer to place number of bytes written
|
* BytesWritten = Address of buffer to place number of bytes written
|
||||||
* NOTES:
|
* NOTES:
|
||||||
* If the specified buffer is too small, a new buffer is allocated,
|
* If the specified buffer is too small, a new buffer is allocated,
|
||||||
|
@ -570,33 +572,17 @@ MiniQueryInformation(
|
||||||
|
|
||||||
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
|
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
|
||||||
|
|
||||||
if (Adapter->QueryBufferLength == 0)
|
|
||||||
{
|
|
||||||
/* XXX is 32 the right number? */
|
|
||||||
Adapter->QueryBuffer = ExAllocatePool(NonPagedPool, (Size == 0)? 32 : Size);
|
|
||||||
|
|
||||||
if (!Adapter->QueryBuffer)
|
|
||||||
{
|
|
||||||
NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
|
||||||
return NDIS_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ditto */
|
|
||||||
Adapter->QueryBufferLength = (Size == 0)? 32 : Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this is the third time i've seen this conditional */
|
|
||||||
BytesNeeded = (Size == 0)? Adapter->QueryBufferLength : Size;
|
|
||||||
|
|
||||||
/* call the miniport's queryinfo handler */
|
/* call the miniport's queryinfo handler */
|
||||||
NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
|
NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
|
||||||
Adapter->NdisMiniportBlock.MiniportAdapterContext,
|
Adapter->NdisMiniportBlock.MiniportAdapterContext,
|
||||||
Oid,
|
Oid,
|
||||||
Adapter->QueryBuffer,
|
Buffer,
|
||||||
BytesNeeded,
|
Size,
|
||||||
BytesWritten,
|
BytesWritten,
|
||||||
&BytesNeeded);
|
&BytesNeeded);
|
||||||
|
|
||||||
|
/* FIXME: Wait in pending case! */
|
||||||
|
|
||||||
/* XXX is status_pending part of success macro? */
|
/* XXX is status_pending part of success macro? */
|
||||||
if ((NT_SUCCESS(NdisStatus)) || (NdisStatus == NDIS_STATUS_PENDING))
|
if ((NT_SUCCESS(NdisStatus)) || (NdisStatus == NDIS_STATUS_PENDING))
|
||||||
{
|
{
|
||||||
|
@ -604,28 +590,6 @@ MiniQueryInformation(
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NdisStatus == NDIS_STATUS_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
ExFreePool(Adapter->QueryBuffer);
|
|
||||||
|
|
||||||
Adapter->QueryBufferLength += BytesNeeded;
|
|
||||||
Adapter->QueryBuffer = ExAllocatePool(NonPagedPool, Adapter->QueryBufferLength);
|
|
||||||
|
|
||||||
if (!Adapter->QueryBuffer)
|
|
||||||
{
|
|
||||||
NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
|
||||||
return NDIS_STATUS_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
|
|
||||||
Adapter->NdisMiniportBlock.MiniportAdapterContext,
|
|
||||||
Oid,
|
|
||||||
Adapter->QueryBuffer,
|
|
||||||
Adapter->QueryBufferLength,
|
|
||||||
BytesWritten,
|
|
||||||
&BytesNeeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,7 +1131,9 @@ DoQueries(
|
||||||
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
||||||
|
|
||||||
/* Get MAC options for adapter */
|
/* Get MAC options for adapter */
|
||||||
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAC_OPTIONS, 0, &BytesWritten);
|
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAC_OPTIONS, sizeof(UINT),
|
||||||
|
&Adapter->NdisMiniportBlock.MacOptions,
|
||||||
|
&BytesWritten);
|
||||||
|
|
||||||
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -1175,12 +1141,11 @@ DoQueries(
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlCopyMemory(&Adapter->NdisMiniportBlock.MacOptions, Adapter->QueryBuffer, sizeof(UINT));
|
|
||||||
|
|
||||||
NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
|
NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
|
||||||
|
|
||||||
/* Get current hardware address of adapter */
|
/* Get current hardware address of adapter */
|
||||||
NdisStatus = MiniQueryInformation(Adapter, AddressOID, 0, &BytesWritten);
|
NdisStatus = MiniQueryInformation(Adapter, AddressOID, Adapter->AddressLength,
|
||||||
|
&Adapter->Address, &BytesWritten);
|
||||||
|
|
||||||
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -1188,7 +1153,6 @@ DoQueries(
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlCopyMemory(&Adapter->Address, Adapter->QueryBuffer, Adapter->AddressLength);
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
{
|
{
|
||||||
/* 802.3 only */
|
/* 802.3 only */
|
||||||
|
@ -1200,7 +1164,8 @@ DoQueries(
|
||||||
#endif /* DBG */
|
#endif /* DBG */
|
||||||
|
|
||||||
/* Get maximum lookahead buffer size of adapter */
|
/* Get maximum lookahead buffer size of adapter */
|
||||||
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_LOOKAHEAD, 0, &BytesWritten);
|
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_LOOKAHEAD, sizeof(ULONG),
|
||||||
|
&Adapter->NdisMiniportBlock.MaximumLookahead, &BytesWritten);
|
||||||
|
|
||||||
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -1208,12 +1173,11 @@ DoQueries(
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter->NdisMiniportBlock.MaximumLookahead = *((PULONG)Adapter->QueryBuffer);
|
|
||||||
|
|
||||||
NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
|
NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
|
||||||
|
|
||||||
/* Get current lookahead buffer size of adapter */
|
/* Get current lookahead buffer size of adapter */
|
||||||
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, 0, &BytesWritten);
|
NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, sizeof(ULONG),
|
||||||
|
&Adapter->NdisMiniportBlock.CurrentLookahead, &BytesWritten);
|
||||||
|
|
||||||
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
if (NdisStatus != NDIS_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -1221,8 +1185,6 @@ DoQueries(
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter->NdisMiniportBlock.CurrentLookahead = *((PULONG)Adapter->QueryBuffer);
|
|
||||||
|
|
||||||
NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
|
NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
|
||||||
|
|
||||||
if (Adapter->NdisMiniportBlock.MaximumLookahead != 0)
|
if (Adapter->NdisMiniportBlock.MaximumLookahead != 0)
|
||||||
|
|
Loading…
Reference in a new issue