Author: cgutman
Date: Thu Aug 21 09:46:03 2008
New Revision: 35507
URL:
http://svn.reactos.org/svn/reactos?rev=35507&view=rev
Log:
- Replace MmMapLockedPages with MmGetSystemAddressForMdlSafe
- Add a check to UnlockRequest
- Enclose MmProbeAndLockPages in SEH
- Fixes bug 3672
Modified:
branches/aicom-network-fixes/drivers/network/afd/afd/lock.c
Modified: branches/aicom-network-fixes/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/afd/afd/lock.c [iso-8859-1] (original)
+++ branches/aicom-network-fixes/drivers/network/afd/afd/lock.c [iso-8859-1] Thu Aug 21
09:46:03 2008
@@ -37,7 +37,7 @@
}
IrpSp->Parameters.DeviceIoControl.Type3InputBuffer =
- MmMapLockedPages( Irp->MdlAddress, KernelMode );
+ MmGetSystemAddressForMdlSafe( Irp->MdlAddress, NormalPagePriority );
if( !IrpSp->Parameters.DeviceIoControl.Type3InputBuffer ) {
IoFreeMdl( Irp->MdlAddress );
@@ -50,12 +50,13 @@
}
VOID UnlockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
- if( !IrpSp->Parameters.DeviceIoControl.Type3InputBuffer || !Irp->MdlAddress )
return;
-
- MmUnmapLockedPages( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
- Irp->MdlAddress );
- MmUnlockPages( Irp->MdlAddress );
- IoFreeMdl( Irp->MdlAddress );
+ PVOID Buffer = MmGetSystemAddressForMdlSafe( Irp->MdlAddress, NormalPagePriority
);
+ if( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer == Buffer || Buffer == NULL
) {
+ MmUnmapLockedPages( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
Irp->MdlAddress );
+ MmUnlockPages( Irp->MdlAddress );
+ IoFreeMdl( Irp->MdlAddress );
+ }
+
Irp->MdlAddress = NULL;
}
@@ -72,6 +73,7 @@
UINT Size = sizeof(AFD_WSABUF) * (Count + Lock);
PAFD_WSABUF NewBuf = ExAllocatePool( PagedPool, Size * 2 );
PMDL NewMdl;
+ BOOLEAN LockFailed = FALSE;
AFD_DbgPrint(MID_TRACE,("Called(%08x)\n", NewBuf));
@@ -117,9 +119,19 @@
if( MapBuf[i].Mdl ) {
AFD_DbgPrint(MID_TRACE,("Probe and lock pages\n"));
- MmProbeAndLockPages( MapBuf[i].Mdl, KernelMode,
- Write ? IoModifyAccess : IoReadAccess );
+ _SEH_TRY {
+ MmProbeAndLockPages( MapBuf[i].Mdl, KernelMode,
+ Write ? IoModifyAccess : IoReadAccess );
+ } _SEH_HANDLE {
+ LockFailed = TRUE;
+ } _SEH_END;
AFD_DbgPrint(MID_TRACE,("MmProbeAndLock finished\n"));
+
+ if( LockFailed ) {
+ IoFreeMdl( MapBuf[i].Mdl );
+ MapBuf[i].Mdl = NULL;
+ LockFailed = FALSE;
+ }
}
}
}