Author: cgutman
Date: Thu Sep 11 23:08:55 2008
New Revision: 36152
URL:
http://svn.reactos.org/svn/reactos?rev=36152&view=rev
Log:
- Merge aicom-network-fixes up to r36151
Modified:
trunk/reactos/drivers/network/afd/afd/context.c
trunk/reactos/drivers/network/afd/afd/lock.c
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/select.c
trunk/reactos/drivers/network/lan/lan/lan.c
trunk/reactos/drivers/network/ndis/ndis/config.c
trunk/reactos/drivers/network/ndis/ndis/io.c
trunk/reactos/drivers/network/ndis/ndis/miniport.c
trunk/reactos/drivers/network/ndis/ndis/protocol.c
trunk/reactos/drivers/network/ndis/ndis/stubs.c
trunk/reactos/drivers/network/tcpip/datalink/lan.c
Modified: trunk/reactos/drivers/network/afd/afd/context.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/context.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/context.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -39,7 +39,6 @@
NTSTATUS STDCALL
AfdSetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp ) {
- NTSTATUS Status = STATUS_BUFFER_TOO_SMALL;
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
@@ -47,25 +46,19 @@
if( FCB->Context ) {
ExFreePool( FCB->Context );
- FCB->Context = NULL;
+ FCB->ContextSize = 0;
}
- if( FCB->ContextSize <
- IrpSp->Parameters.DeviceIoControl.InputBufferLength ) {
- FCB->Context =
- ExAllocatePool
- ( PagedPool,
- IrpSp->Parameters.DeviceIoControl.InputBufferLength );
+ FCB->Context = ExAllocatePool( PagedPool,
+ IrpSp->Parameters.DeviceIoControl.InputBufferLength );
- if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0,
NULL );
+ if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0,
NULL );
- RtlCopyMemory( FCB->Context,
- IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
- IrpSp->Parameters.DeviceIoControl.InputBufferLength );
- Status = STATUS_SUCCESS;
- }
+ FCB->ContextSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
- AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
+ RtlCopyMemory( FCB->Context,
+ IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
+ FCB->ContextSize );
- return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
+ return UnlockAndMaybeComplete( FCB, STATUS_SUCCESS, Irp, 0, NULL );
}
Modified: trunk/reactos/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/lo…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -174,8 +174,8 @@
( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) );
for( i = 0; FileObjects && i < HandleCount; i++ ) {
- HandleArray[i].Status = 0;
- HandleArray[i].Events = HandleArray[i].Events;
+ FileObjects[i].Status = 0;
+ FileObjects[i].Events = HandleArray[i].Events;
FileObjects[i].Handle = 0;
if( !HandleArray[i].Handle ) continue;
if( NT_SUCCESS(Status) ) {
@@ -206,6 +206,7 @@
}
ExFreePool( HandleArray );
+ HandleArray = NULL;
}
/* Returns transitioned state or SOCKET_STATE_INVALID_TRANSITION */
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -52,6 +52,7 @@
ULONG EaLength;
PWCHAR EaInfoValue = NULL;
UINT Disposition, i;
+ NTSTATUS Status = STATUS_SUCCESS;
AFD_DbgPrint(MID_TRACE,
("AfdCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp));
@@ -140,16 +141,27 @@
AFD_DbgPrint(MID_TRACE,("Packet oriented socket\n"));
/* Allocate our backup buffer */
FCB->Recv.Window = ExAllocatePool( NonPagedPool, FCB->Recv.Size );
+ if( !FCB->Recv.Window ) Status = STATUS_NO_MEMORY;
FCB->Send.Window = ExAllocatePool( NonPagedPool, FCB->Send.Size );
+ if( !FCB->Send.Window ) {
+ if( FCB->Recv.Window ) ExFreePool( FCB->Recv.Window );
+ Status = STATUS_NO_MEMORY;
+ }
/* A datagram socket is always sendable */
FCB->PollState |= AFD_EVENT_SEND;
PollReeval( FCB->DeviceExt, FCB->FileObject );
}
- Irp->IoStatus.Status = STATUS_SUCCESS;
+ if( !NT_SUCCESS(Status) ) {
+ if( FCB->TdiDeviceName.Buffer ) ExFreePool( FCB->TdiDeviceName.Buffer );
+ ExFreePool( FCB );
+ FileObject->FsContext = NULL;
+ }
+
+ Irp->IoStatus.Status = Status;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
- return STATUS_SUCCESS;
+ return Status;
}
VOID DestroySocket( PAFD_FCB FCB ) {
Modified: trunk/reactos/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -642,6 +642,7 @@
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
PollReeval( FCB->DeviceExt, FCB->FileObject );
+ UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE );
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
} else {
PollReeval( FCB->DeviceExt, FCB->FileObject );
Modified: trunk/reactos/drivers/network/afd/afd/select.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -311,7 +311,7 @@
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
- return UnlockAndMaybeComplete( FCB, STATUS_SUCCESS, Irp,
+ return UnlockAndMaybeComplete( FCB, Status, Irp,
0, NULL );
}
Modified: trunk/reactos/drivers/network/lan/lan/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/lan/lan/la…
==============================================================================
--- trunk/reactos/drivers/network/lan/lan/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/lan/lan/lan.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -349,7 +349,10 @@
/* Get a transfer data packet */
KeAcquireSpinLockAtDpcLevel(&Adapter->Lock);
NdisStatus = AllocatePacketWithBuffer( &NdisPacket, NULL, Adapter->MTU );
- if( NdisStatus != NDIS_STATUS_SUCCESS ) return NDIS_STATUS_NOT_ACCEPTED;
+ if( NdisStatus != NDIS_STATUS_SUCCESS ) {
+ KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
+ return NDIS_STATUS_NOT_ACCEPTED;
+ }
LA_DbgPrint(DEBUG_DATALINK, ("pretransfer LookaheadBufferSize %d packsize
%d\n",LookaheadBufferSize,PacketSize));
{
UINT temp;
Modified: trunk/reactos/drivers/network/ndis/ndis/config.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] Thu Sep 11 23:08:55
2008
@@ -283,6 +283,7 @@
if(!ConfigurationContext)
{
NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ZwClose(KeyHandle);
*ConfigurationHandle = NULL;
*Status = NDIS_STATUS_FAILURE;
return;
@@ -849,6 +850,7 @@
if(!ConfigurationContext)
{
NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ZwClose(RegKeyHandle);
*Status = NDIS_STATUS_FAILURE;
return;
}
@@ -907,6 +909,7 @@
if(!ConfigurationContext)
{
NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ZwClose(RegKeyHandle);
*Status = NDIS_STATUS_FAILURE;
return;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -407,6 +407,7 @@
if(!NT_SUCCESS(NtStatus))
{
NDIS_DbgPrint(MIN_TRACE, ("IoAllocateAdapterChannel failed: 0x%x\n",
NtStatus));
+ ExFreePool(Adapter->MapRegisters);
return NDIS_STATUS_RESOURCES;
}
@@ -417,6 +418,7 @@
if(!NT_SUCCESS(NtStatus))
{
NDIS_DbgPrint(MIN_TRACE, ("KeWaitForSingleObject failed: 0x%x\n",
NtStatus));
+ ExFreePool(Adapter->MapRegisters);
return NDIS_STATUS_RESOURCES;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Thu Sep 11 23:08:55
2008
@@ -314,15 +314,18 @@
IN NDIS_STATUS Status)
{
PNDIS_REQUEST_MAC_BLOCK MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
if( MacBlock->Binding->RequestCompleteHandler ) {
(*MacBlock->Binding->RequestCompleteHandler)(
MacBlock->Binding->ProtocolBindingContext,
Request,
Status);
}
+ KeLowerIrql(OldIrql);
}
VOID NTAPI
@@ -340,15 +343,18 @@
*/
{
PADAPTER_BINDING AdapterBinding;
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeLowerIrql(OldIrql);
}
@@ -370,15 +376,18 @@
IN UINT BytesTransferred)
{
PADAPTER_BINDING AdapterBinding;
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[0];
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
(*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
Packet,
Status);
+ KeLowerIrql(OldIrql);
}
@@ -548,10 +557,12 @@
{
NDIS_STATUS NdisStatus;
ULONG BytesNeeded;
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
/* call the miniport's queryinfo handler */
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
NdisStatus =
(*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
Adapter->NdisMiniportBlock.MiniportAdapterContext,
Oid,
@@ -559,6 +570,7 @@
Size,
BytesWritten,
&BytesNeeded);
+ KeLowerIrql(OldIrql);
/* FIXME: Wait in pending case! */
@@ -678,14 +690,17 @@
* Status of operation
*/
{
+ NDIS_STATUS Status;
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
Adapter->MediaRequest = NdisRequest;
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
switch (NdisRequest->RequestType)
{
case NdisRequestQueryInformation:
- return
(*Adapter->DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
+ Status =
(*Adapter->DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
Adapter->MiniportAdapterContext,
NdisRequest->DATA.QUERY_INFORMATION.Oid,
NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
@@ -695,7 +710,7 @@
break;
case NdisRequestSetInformation:
- return
(*Adapter->DriverHandle->MiniportCharacteristics.SetInformationHandler)(
+ Status =
(*Adapter->DriverHandle->MiniportCharacteristics.SetInformationHandler)(
Adapter->MiniportAdapterContext,
NdisRequest->DATA.SET_INFORMATION.Oid,
NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
@@ -705,8 +720,11 @@
break;
default:
- return NDIS_STATUS_FAILURE;
- }
+ Status = NDIS_STATUS_FAILURE;
+ }
+
+ KeLowerIrql(OldIrql);
+ return Status;
}
@@ -722,9 +740,12 @@
{
PNDIS_MINIPORT_BLOCK MiniportBlock =
(PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+ KIRQL OldIrql;
ASSERT(MiniportBlock);
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
if( MiniportBlock->QueryCompleteHandler )
(MiniportBlock->QueryCompleteHandler)(MiniportAdapterHandle, Status);
+ KeLowerIrql(OldIrql);
}
@@ -746,8 +767,11 @@
PVOID WorkItemContext;
NDIS_WORK_ITEM_TYPE WorkItemType;
PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(DeferredContext);
+ KIRQL OldIrql;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
+
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
NdisStatus =
MiniDequeueWorkItem
@@ -845,6 +869,8 @@
break;
}
}
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
}
@@ -1281,6 +1307,7 @@
if (!NT_SUCCESS(Status))
{
NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
+ ExInterlockedRemoveEntryList( &Adapter->ListEntry, &AdapterListLock );
return Status;
}
@@ -1909,7 +1936,10 @@
IN NDIS_HANDLE MiniportAdapterHandle,
IN NDIS_STATUS Status)
{
+ KIRQL OldIrql;
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
(*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->SetCompleteHandler)(MiniportAdapterHandle,
Status);
+ KeLowerIrql(OldIrql);
}
Modified: trunk/reactos/drivers/network/ndis/ndis/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/protocol.c [iso-8859-1] Thu Sep 11 23:08:55
2008
@@ -238,7 +238,6 @@
*/
NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &SpinOldIrql);
- {
/*
* if the miniport is marked as busy, we queue the packet as a work item,
* else we send the packet directly to the miniport. Sending to the miniport
@@ -251,8 +250,6 @@
NDIS_DbgPrint(MAX_TRACE, ("Setting adapter 0x%x to busy\n"));
Adapter->MiniportBusy = TRUE;
}
- }
- KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
/*
* Test the packet to see if it is a MAC loopback.
@@ -269,8 +266,11 @@
if (QueueWorkItem)
{
MiniQueueWorkItem(Adapter, NdisWorkItemSendLoopback, (PVOID)Packet);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
return NDIS_STATUS_PENDING;
}
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
{
@@ -306,11 +306,14 @@
if (QueueWorkItem)
{
MiniQueueWorkItem(Adapter, NdisWorkItemSend, (PVOID)Packet);
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
NDIS_DbgPrint(MAX_TRACE, ("Queued a work item and returning\n"));
return NDIS_STATUS_PENDING;
}
ASSERT(Adapter->NdisMiniportBlock.DriverHandle);
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, SpinOldIrql);
/*
* Call the appropriate send handler
Modified: trunk/reactos/drivers/network/ndis/ndis/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/stubs.c [iso-8859-1] Thu Sep 11 23:08:55 2008
@@ -301,7 +301,10 @@
memmove ( FullFileName.Buffer, NDIS_FILE_FOLDER, FullFileName.Length );
*Status = RtlAppendUnicodeStringToString ( &FullFileName, FileName );
if ( !NT_SUCCESS(*Status) )
+ {
+ *Status = NDIS_STATUS_FAILURE;
goto cleanup;
+ }
InitializeObjectAttributes ( &ObjectAttributes,
&FullFileName,
@@ -321,6 +324,11 @@
FILE_SYNCHRONOUS_IO_NONALERT, // ULONG CreateOptions
0, // PVOID EaBuffer
0 ); // ULONG EaLength
+
+ if ( !NT_SUCCESS(*Status) )
+ {
+ *Status = NDIS_STATUS_FAILURE;
+ }
cleanup:
if ( FullFileName.Buffer != NULL )
Modified: trunk/reactos/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/data…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Thu Sep 11 23:08:55
2008
@@ -595,7 +595,6 @@
PETH_HEADER EHeader;
PCHAR Data;
UINT Size;
- KIRQL OldIrql;
PLAN_ADAPTER Adapter = (PLAN_ADAPTER)Context;
TI_DbgPrint(DEBUG_DATALINK,
@@ -673,13 +672,11 @@
((PCHAR)LinkAddress)[5] & 0xff));
}
- TcpipAcquireSpinLock( &Adapter->Lock, &OldIrql );
TI_DbgPrint(MID_TRACE, ("NdisSend\n"));
NdisSend(&NdisStatus, Adapter->NdisHandle, NdisPacket);
TI_DbgPrint(MID_TRACE, ("NdisSend %s\n",
NdisStatus == NDIS_STATUS_PENDING ?
"Pending" : "Complete"));
- TcpipReleaseSpinLock( &Adapter->Lock, OldIrql );
/* I had a talk with vizzini: these really ought to be here.
* we're supposed to see these completed by ndis *only* when
@@ -861,6 +858,11 @@
ExFreePool( Kbio );
KbioLength = ResultLength;
Kbio = ExAllocatePool( NonPagedPool, KbioLength );
+ if( !Kbio ) {
+ TI_DbgPrint(DEBUG_DATALINK,("Failed to allocate memory\n"));
+ NtClose( EnumKey );
+ return STATUS_NO_MEMORY;
+ }
Status = ZwEnumerateKey( EnumKey, i, KeyBasicInformation,
Kbio, KbioLength, &ResultLength );
@@ -1262,7 +1264,7 @@
FreeAdapter(Adapter);
- return NDIS_STATUS_SUCCESS;
+ return NdisStatus;
}