From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 13B63803ED for ; Tue, 21 Mar 2017 18:33:16 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 21 Mar 2017 18:33:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,202,1486454400"; d="scan'208";a="837229328" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.148]) by FMSMGA003.fm.intel.com with ESMTP; 21 Mar 2017 18:33:14 -0700 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Zhang Lubo , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Wed, 22 Mar 2017 09:33:12 +0800 Message-Id: <1490146392-2804-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in DriverEntryPoint X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 01:33:16 -0000 Currently, error handling in IScsiDriverEntryPoint is incorrect. For example, if IScsiCreateAttempts() return error due to the limited max variable size, iSCSI will not unload the configuration entries. Cc: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiDriver.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c index 269c1ae..2249919 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -1811,11 +1811,11 @@ IScsiDriverEntryPoint ( // // Create Keywords for all the Attempts. // Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber)); if (EFI_ERROR (Status)) { - goto Error5; + goto Error6; } // // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists, // do not produce the protocol instance. @@ -1838,17 +1838,20 @@ IScsiDriverEntryPoint ( } return EFI_SUCCESS; Error6: - IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle); + IScsiCleanAttemptVariable (); Error5: - IScsiCleanAttemptVariable (); + IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle); Error4: - FreePool (mPrivate); + if (mPrivate != NULL) { + FreePool (mPrivate); + mPrivate = NULL; + } Error3: gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiIScsiInitiatorNameProtocolGuid, -- 1.9.5.msysgit.1