From ca4e58d8e390794e9fd8b7eb46073260d19f5e1d Mon Sep 17 00:00:00 2001 From: Fu Siyuan Date: Fri, 24 Jan 2014 05:33:18 +0000 Subject: [PATCH] =?utf8?q?Fix=20following=20problems=20about=20VLAN=20driv?= =?utf8?q?er:=201.=20"VLAN=20Configuration=E2=80=9D=20form=20crash=20after?= =?utf8?q?=20'reconnect=20-r'=202.=20disconnect=20VLAN=20driver=20from=20t?= =?utf8?q?he=20managed=20device=20will=20return=20EFI=5FNOT=5FFOUND=203.?= =?utf8?q?=20disconnect=20MNP=20driver=20from=20the=20managed=20device,=20?= =?utf8?q?VLAN=20driver=20couldn't=20be=20stopped.=20Signed-off-by:=20Fu?= =?utf8?q?=20Siyuan=20=20Reviewed-by:=20Ni,=20Ruiyu?= =?utf8?q?=20=20Reviewed-by:=20Gao,=20Liming=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15174 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Network/VlanConfigDxe/VlanConfigDriver.c | 13 +-- .../Network/VlanConfigDxe/VlanConfigImpl.c | 85 ++++++++++++------- .../Network/VlanConfigDxe/VlanConfigImpl.h | 7 +- 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c index 52bb99fa5d..7dfea2e32a 100644 --- a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c +++ b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding for VLAN configuration module. -Copyright (c) 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
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 @@ -275,10 +275,13 @@ VlanConfigDriverBindingStop ( } ASSERT (PrivateData->Signature == VLAN_CONFIG_PRIVATE_DATA_SIGNATURE); - // - // Uninstall VLAN configuration Form - // - UninstallVlanConfigForm (PrivateData); + if (NumberOfChildren != 0) { + if (NumberOfChildren != 1 || ChildHandleBuffer[0] != PrivateData->DriverHandle) { + return EFI_DEVICE_ERROR; + } + + return UninstallVlanConfigForm (PrivateData); + } // // Uninstall the private GUID diff --git a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c index 10fb7fa670..fd8555e30e 100644 --- a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c +++ b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.c @@ -1,7 +1,7 @@ /** @file HII Config Access protocol implementation of VLAN configuration module. -Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
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 @@ -588,50 +588,54 @@ InstallVlanConfigForm ( @param[in, out] PrivateData Points to VLAN configuration private data. + @retval EFI_SUCCESS HII Form has been uninstalled successfully. + @retval Others Other errors as indicated. + **/ -VOID +EFI_STATUS UninstallVlanConfigForm ( IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData ) { - // - // Free MAC string - // - if (PrivateData->MacString != NULL) { - FreePool (PrivateData->MacString); - PrivateData->MacString = NULL; - } - - // - // Uninstall HII package list - // - if (PrivateData->HiiHandle != NULL) { - HiiRemovePackages (PrivateData->HiiHandle); - PrivateData->HiiHandle = NULL; - } - + EFI_STATUS Status; + EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; + // // End the parent-child relationship. // - gBS->CloseProtocol ( - PrivateData->ControllerHandle, - &gEfiVlanConfigProtocolGuid, - PrivateData->ImageHandle, - PrivateData->DriverHandle - ); + Status = gBS->CloseProtocol ( + PrivateData->ControllerHandle, + &gEfiVlanConfigProtocolGuid, + PrivateData->ImageHandle, + PrivateData->DriverHandle + ); + if (EFI_ERROR (Status)) { + return Status; + } // // Uninstall HII Config Access Protocol // if (PrivateData->DriverHandle != NULL) { - gBS->UninstallMultipleProtocolInterfaces ( - PrivateData->DriverHandle, - &gEfiDevicePathProtocolGuid, - PrivateData->ChildDevicePath, - &gEfiHiiConfigAccessProtocolGuid, - &PrivateData->ConfigAccess, - NULL - ); + Status = gBS->UninstallMultipleProtocolInterfaces ( + PrivateData->DriverHandle, + &gEfiDevicePathProtocolGuid, + PrivateData->ChildDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &PrivateData->ConfigAccess, + NULL + ); + if (EFI_ERROR (Status)) { + gBS->OpenProtocol ( + PrivateData->ControllerHandle, + &gEfiVlanConfigProtocolGuid, + (VOID **)&VlanConfig, + PrivateData->ImageHandle, + PrivateData->DriverHandle, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER + ); + return Status; + } PrivateData->DriverHandle = NULL; if (PrivateData->ChildDevicePath != NULL) { @@ -639,4 +643,21 @@ UninstallVlanConfigForm ( PrivateData->ChildDevicePath = NULL; } } + + // + // Free MAC string + // + if (PrivateData->MacString != NULL) { + FreePool (PrivateData->MacString); + PrivateData->MacString = NULL; + } + + // + // Uninstall HII package list + // + if (PrivateData->HiiHandle != NULL) { + HiiRemovePackages (PrivateData->HiiHandle); + PrivateData->HiiHandle = NULL; + } + return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h index a1c0b2a35d..2aa43b4230 100644 --- a/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h +++ b/MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigImpl.h @@ -1,7 +1,7 @@ /** @file Header file for driver binding protocol and HII config access protocol. -Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
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 @@ -282,8 +282,11 @@ InstallVlanConfigForm ( @param[in, out] PrivateData Points to VLAN configuration private data. + @retval EFI_SUCCESS HII Form has been uninstalled successfully. + @retval Others Other errors as indicated. + **/ -VOID +EFI_STATUS UninstallVlanConfigForm ( IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData ); -- 2.39.2