summaryrefslogtreecommitdiff
path: root/OptionRomPkg/UndiRuntimeDxe/Init.c
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2012-10-03 23:49:50 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2012-10-03 23:49:50 +0000
commit4a823e23b119bfb9b0182e8717a0ea5139f82190 (patch)
tree83e5a2cfb12cc27310bb88f074e2bfefb2e6737f /OptionRomPkg/UndiRuntimeDxe/Init.c
parentbbcafc442b2db91322dd3ba04e166236a41b111d (diff)
downloadedk2-platforms-4a823e23b119bfb9b0182e8717a0ea5139f82190.tar.xz
The Driver Binding Protocol Stop() function for the UndiRuntimeDxe is performing actions in the incorrect order. The call to UninstallMultipleProtocolInterfaces() removes all the protocols from the child handle, which means ChildHandleBuffer[Index] is no longer valid. After the call to UninstallMultipleProtocolInterfaces(), ChildHandleBuffer[Index] is used again in a call to CloseProtocol(). The handle is not valid, so CloseProtocol() returns an error and generates an ASSERT().
This patch changes the order to call CloseProtocol() before calling UninstallMultipleProtocolInterfaces(). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13781 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OptionRomPkg/UndiRuntimeDxe/Init.c')
-rw-r--r--OptionRomPkg/UndiRuntimeDxe/Init.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/OptionRomPkg/UndiRuntimeDxe/Init.c b/OptionRomPkg/UndiRuntimeDxe/Init.c
index 10c26ad438..49ec0d5ded 100644
--- a/OptionRomPkg/UndiRuntimeDxe/Init.c
+++ b/OptionRomPkg/UndiRuntimeDxe/Init.c
@@ -1,7 +1,7 @@
/** @file
Initialization functions for EFI UNDI32 driver.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -616,38 +616,38 @@ UndiDriverStop (
UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- UNDI32Device->Undi32DevPath,
- &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- &UNDI32Device->NIIProtocol_31,
- NULL
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ ChildHandleBuffer[Index]
);
if (!EFI_ERROR (Status)) {
- //
- // Restore original PCI attributes
- //
- Status = UNDI32Device->NicInfo.Io_Function->Attributes (
- UNDI32Device->NicInfo.Io_Function,
- EfiPciIoAttributeOperationSet,
- UNDI32Device->NicInfo.OriginalPciAttributes,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ChildHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ UNDI32Device->Undi32DevPath,
+ &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
+ &UNDI32Device->NIIProtocol_31,
+ NULL
);
-
- ASSERT_EFI_ERROR (Status);
-
- gBS->FreePool (UNDI32Device->Undi32DevPath);
- gBS->FreePool (UNDI32Device);
-
+ if (!EFI_ERROR (Status)) {
+ //
+ // Restore original PCI attributes
+ //
+ Status = UNDI32Device->NicInfo.Io_Function->Attributes (
+ UNDI32Device->NicInfo.Io_Function,
+ EfiPciIoAttributeOperationSet,
+ UNDI32Device->NicInfo.OriginalPciAttributes,
+ NULL
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->FreePool (UNDI32Device->Undi32DevPath);
+ gBS->FreePool (UNDI32Device);
+
+ }
}
}