From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D566211C7F2A for ; Sat, 2 Feb 2019 22:23:08 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2019 22:23:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,555,1539673200"; d="scan'208";a="114881685" Received: from jiaxinwu-mobl.ccr.corp.intel.com ([10.239.192.99]) by orsmga008.jf.intel.com with ESMTP; 02 Feb 2019 22:23:06 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Michael Turner , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Sun, 3 Feb 2019 14:22:57 +0800 Message-Id: <20190203062257.7128-3-Jiaxin.wu@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190203062257.7128-1-Jiaxin.wu@intel.com> References: <20190203062257.7128-1-Jiaxin.wu@intel.com> Subject: [PATCH v1 2/2] NetworkPkg/Ip6Dxe: Uninstall protocols when error happen in Driver Binding Start. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2019 06:23:08 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1447 This patch is to uninstall Ip6ServiceBindingProtocol and Ip6ConfigProtocol when error happen in Driver Binding Start. Cc: Michael Turner Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin Signed-off-by: Michael Turner --- NetworkPkg/Ip6Dxe/Ip6Driver.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c index 0bda1687f0..4c607125a6 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c @@ -1,9 +1,9 @@ /** @file The driver binding and service binding protocol for IP6 driver. - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
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 @@ -562,20 +562,20 @@ Ip6DriverBindingStart ( &gEfiIp6ConfigProtocolGuid, Ip6Cfg, NULL ); if (EFI_ERROR (Status)) { - goto ON_ERROR; + goto FREE_SERVICE; } // // Read the config data from NV variable again. // The default data can be changed by other drivers. // Status = Ip6ConfigReadConfigData (IpSb->MacString, &IpSb->Ip6ConfigInstance); if (EFI_ERROR (Status)) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } // // If there is any default manual address, set it. // @@ -586,11 +586,11 @@ Ip6DriverBindingStart ( Ip6ConfigDataTypeManualAddress, DataItem->DataSize, DataItem->Data.Ptr ); if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } } // // If there is any default gateway address, set it. @@ -602,20 +602,20 @@ Ip6DriverBindingStart ( Ip6ConfigDataTypeGateway, DataItem->DataSize, DataItem->Data.Ptr ); if (EFI_ERROR(Status)) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } } // // ready to go: start the receiving and timer // Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb); if (EFI_ERROR (Status)) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } // // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds. // @@ -623,11 +623,11 @@ Ip6DriverBindingStart ( IpSb->FasterTimer, TimerPeriodic, TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS ); if (EFI_ERROR (Status)) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } // // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds. // @@ -635,21 +635,31 @@ Ip6DriverBindingStart ( IpSb->Timer, TimerPeriodic, TICKS_PER_MS * IP6_ONE_SECOND_IN_MS ); if (EFI_ERROR (Status)) { - goto ON_ERROR; + goto UNINSTALL_PROTOCOL; } // // Initialize the IP6 ID // mIp6Id = NET_RANDOM (NetRandomInitSeed ()); return EFI_SUCCESS; -ON_ERROR: +UNINSTALL_PROTOCOL: + gBS->UninstallMultipleProtocolInterfaces ( + ControllerHandle, + &gEfiIp6ServiceBindingProtocolGuid, + &IpSb->ServiceBinding, + &gEfiIp6ConfigProtocolGuid, + Ip6Cfg, + NULL + ); + +FREE_SERVICE: Ip6CleanService (IpSb); FreePool (IpSb); return Status; } -- 2.17.1.windows.2