Author: cgutman
Date: Sat Sep 27 14:00:47 2008
New Revision: 36556
URL:
http://svn.reactos.org/svn/reactos?rev=36556&view=rev
Log:
- Protect MiniportBusy with a spin lock
- Adapter is PLOGICAL_ADAPTER not PNDIS_MINIPORT_BLOCK
- Make sure memory allocation was successful
- Cleanup code in ProRequest
Modified:
branches/aicom-network-fixes/drivers/network/ndis/include/miniport.h
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/include/miniport.h
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/ndis/include/miniport.h [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/ndis/include/miniport.h [iso-8859-1] Sat
Sep 27 14:00:47 2008
@@ -146,7 +146,7 @@
NDIS_STATUS
MiniDoRequest(
- PNDIS_MINIPORT_BLOCK Adapter,
+ PLOGICAL_ADAPTER Adapter,
PNDIS_REQUEST NdisRequest);
BOOLEAN
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] Sat Sep
27 14:00:47 2008
@@ -326,8 +326,10 @@
Request,
Status);
}
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
VOID NTAPI
@@ -357,8 +359,10 @@
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
@@ -392,8 +396,10 @@
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
@@ -767,7 +773,7 @@
NDIS_STATUS
MiniDoRequest(
- PNDIS_MINIPORT_BLOCK Adapter,
+ PLOGICAL_ADAPTER Adapter,
PNDIS_REQUEST NdisRequest)
/*
* FUNCTION: Sends a request to a miniport
@@ -782,14 +788,14 @@
KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
- Adapter->MediaRequest = NdisRequest;
+ Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
switch (NdisRequest->RequestType)
{
case NdisRequestQueryInformation:
- Status =
(*Adapter->DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid,
NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
@@ -798,8 +804,8 @@
break;
case NdisRequestSetInformation:
- Status =
(*Adapter->DriverHandle->MiniportCharacteristics.SetInformationHandler)(
- Adapter->MiniportAdapterContext,
+ Status =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SetInformationHandler)(
+ Adapter->NdisMiniportBlock.MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid,
NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
@@ -833,8 +839,10 @@
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
if( Adapter->NdisMiniportBlock.QueryCompleteHandler )
(Adapter->NdisMiniportBlock.QueryCompleteHandler)(MiniportAdapterHandle, Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
VOID NTAPI MiniportWorker(IN PVOID WorkItem)
@@ -962,7 +970,7 @@
break;
case NdisWorkItemRequest:
- NdisStatus = MiniDoRequest(&Adapter->NdisMiniportBlock,
(PNDIS_REQUEST)WorkItemContext);
+ NdisStatus = MiniDoRequest(Adapter, (PNDIS_REQUEST)WorkItemContext);
if (NdisStatus == NDIS_STATUS_PENDING)
break;
@@ -1019,6 +1027,7 @@
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
NdisWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_WORK_ITEM));
+ if (!NdisWorkItem) return;
WorkItem = (PWORK_QUEUE_ITEM)NdisWorkItem->WrapperReserved;
@@ -2123,8 +2132,10 @@
ASSERT(Adapter);
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
(Adapter->NdisMiniportBlock.SetCompleteHandler)(MiniportAdapterHandle, Status);
+ KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
+ Adapter->MiniportBusy = FALSE;
+ KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
KeLowerIrql(OldIrql);
- Adapter->MiniportBusy = FALSE;
}
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] Sat Sep
27 14:00:47 2008
@@ -119,8 +119,6 @@
*/
{
KIRQL OldIrql;
- BOOLEAN QueueWorkItem = FALSE;
- NDIS_STATUS NdisStatus;
PADAPTER_BINDING AdapterBinding;
PLOGICAL_ADAPTER Adapter;
PNDIS_REQUEST_MAC_BLOCK MacBlock =
(PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
@@ -141,26 +139,15 @@
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
{
- if(Adapter->MiniportBusy)
- QueueWorkItem = TRUE;
- }
-
- /* MiniQueueWorkItem must be called at IRQL >= DISPATCH_LEVEL */
- if (QueueWorkItem)
- {
- MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
- return NDIS_STATUS_PENDING;
- }
-
+ if (Adapter->MiniportBusy) {
+ MiniQueueWorkItem(Adapter, NdisWorkItemRequest, (PVOID)NdisRequest);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+ return NDIS_STATUS_PENDING;
+ }
+ }
KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
- NdisStatus = MiniDoRequest(&Adapter->NdisMiniportBlock, NdisRequest);
-
- if( NdisStatus == NDIS_STATUS_PENDING )
- Adapter->MiniportBusy = TRUE;
-
- return NdisStatus;
+ return MiniDoRequest(Adapter, NdisRequest);
}