[AFD]
[reactos.git] / reactos / drivers / network / afd / afd / info.c
index 2567d98..162f660 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id$
+/*
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/net/afd/afd/info.c
@@ -7,18 +7,21 @@
  * UPDATE HISTORY:
  * 20040708 Created
  */
+
 #include "afd.h"
 
 NTSTATUS NTAPI
 AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
             PIO_STACK_LOCATION IrpSp ) {
     NTSTATUS Status = STATUS_SUCCESS;
-    PAFD_INFO InfoReq = LockRequest(Irp, IrpSp);
+    PAFD_INFO InfoReq = LockRequest(Irp, IrpSp, TRUE, NULL);
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
     PLIST_ENTRY CurrentEntry;
 
-    AFD_DbgPrint(MID_TRACE,("Called %x %x\n", InfoReq,
+    UNREFERENCED_PARAMETER(DeviceObject);
+
+    AFD_DbgPrint(MID_TRACE,("Called %p %x\n", InfoReq,
                             InfoReq ? InfoReq->InformationClass : 0));
 
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
@@ -34,13 +37,13 @@ AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 
         case AFD_INFO_SEND_WINDOW_SIZE:
             InfoReq->Information.Ulong = FCB->Send.Size;
-            AFD_DbgPrint(MID_TRACE,("Send window size %d\n", FCB->Send.Size));
+            AFD_DbgPrint(MID_TRACE,("Send window size %u\n", FCB->Send.Size));
             break;
 
         case AFD_INFO_GROUP_ID_TYPE:
             InfoReq->Information.LargeInteger.u.HighPart = FCB->GroupType;
             InfoReq->Information.LargeInteger.u.LowPart = FCB->GroupID;
-            AFD_DbgPrint(MID_TRACE, ("Group ID: %d Group Type: %d\n", FCB->GroupID, FCB->GroupType));
+            AFD_DbgPrint(MID_TRACE, ("Group ID: %u Group Type: %u\n", FCB->GroupID, FCB->GroupType));
             break;
 
         case AFD_INFO_BLOCKING_MODE:
@@ -99,11 +102,13 @@ NTSTATUS NTAPI
 AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
             PIO_STACK_LOCATION IrpSp ) {
     NTSTATUS Status = STATUS_SUCCESS;
-    PAFD_INFO InfoReq = LockRequest(Irp, IrpSp);
+    PAFD_INFO InfoReq = LockRequest(Irp, IrpSp, FALSE, NULL);
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
     PCHAR NewBuffer;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+
     if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp);
 
     if (!InfoReq)
@@ -112,7 +117,7 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
     _SEH2_TRY {
         switch (InfoReq->InformationClass) {
             case AFD_INFO_BLOCKING_MODE:
-                AFD_DbgPrint(MID_TRACE,("Blocking mode set to %d\n", InfoReq->Information.Boolean));
+                AFD_DbgPrint(MID_TRACE,("Blocking mode set to %u\n", InfoReq->Information.Boolean));
                 FCB->NonBlocking = InfoReq->Information.Boolean;
                 break;
             case AFD_INFO_INLINING_MODE:
@@ -171,7 +176,7 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
                 }
                 break;
             default:
-                AFD_DbgPrint(MIN_TRACE,("Unknown request %d\n", InfoReq->InformationClass));
+                AFD_DbgPrint(MIN_TRACE,("Unknown request %u\n", InfoReq->InformationClass));
                 break;
         }
     } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
@@ -192,6 +197,9 @@ AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
     PAFD_FCB FCB = FileObject->FsContext;
     PMDL Mdl = NULL;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+    ASSERT(Irp->MdlAddress == NULL);
+
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
 
     if( FCB->AddressFile.Object == NULL && FCB->Connection.Object == NULL ) {
@@ -219,6 +227,11 @@ AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
                                               TDI_QUERY_ADDRESS_INFO,
                                               Mdl );
         }
+
+        /* Check if MmProbeAndLockPages or TdiQueryInformation failed and
+         * clean up Mdl */
+        if (!NT_SUCCESS(Status) && Irp->MdlAddress != Mdl)
+            IoFreeMdl(Mdl);
     } else
         Status = STATUS_INSUFFICIENT_RESOURCES;
 
@@ -232,6 +245,7 @@ AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
     PFILE_OBJECT FileObject = IrpSp->FileObject;
     PAFD_FCB FCB = FileObject->FsContext;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
 
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );