diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c index f8b535cf6e..bca4b02009 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c @@ -162,15 +162,6 @@ SockDestroyChild ( ASSERT (Tcb != NULL); - Status = EfiAcquireLockOrFail (&(Sock->Lock)); - if (EFI_ERROR (Status)) { - - DEBUG ((EFI_D_ERROR, "SockDestroyChild: Get the lock to " - "access socket failed with %r\n", Status)); - - return EFI_ACCESS_DENIED; - } - // // Close the IP protocol. // @@ -214,6 +205,15 @@ SockDestroyChild ( NULL ); + Status = EfiAcquireLockOrFail (&(Sock->Lock)); + if (EFI_ERROR (Status)) { + + DEBUG ((EFI_D_ERROR, "SockDestroyChild: Get the lock to " + "access socket failed with %r\n", Status)); + + return EFI_ACCESS_DENIED; + } + // // force protocol layer to detach the PCB //