From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 27C39211CD9AC for ; Thu, 28 Feb 2019 01:10:33 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 01:10:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,422,1544515200"; d="scan'208";a="119752936" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.28]) by orsmga006.jf.intel.com with ESMTP; 28 Feb 2019 01:10:31 -0800 From: Wang Fan To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Thu, 28 Feb 2019 17:10:09 +0800 Message-Id: <20190228091009.7096-1-fan.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [Patch] NetworkPkg: Fix Duplicate FreePool Error in WCM 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: Thu, 28 Feb 2019 09:10:33 -0000 * REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1577 In WiFi Connection Manager scan process, the result received from WiFi device driver will be freed twice, and will cause unexpected errors, and even system crash. This issue also exists in some other places potentially, this patch is to fix these issues. Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wang Fan --- NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c | 1 + NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrFileUtil.c | 1 + .../WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c | 9 +++++++++ NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c | 1 - 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 1431cdc7ea..63b0670c63 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -409,10 +409,11 @@ WifiMgrDxeDriverBindingStop ( } // // Close Event // + gBS->SetTimer (Nic->TickTimer, TimerCancel, 0); gBS->CloseEvent (Nic->TickTimer); // // Clean Supported Suites // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrFileUtil.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrFileUtil.c index 6db1626f2d..0224823431 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrFileUtil.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrFileUtil.c @@ -251,10 +251,11 @@ UpdatePage( } } else { if (Private->FileContext->FileName != NULL) { FreePool (Private->FileContext->FileName); + Private->FileContext->FileName = NULL; } Private->FileContext->FileName = FileName; if (FormId == FORMID_ENROLL_CERT) { HiiSetString (Private->RegisteredHandle, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c index bfb6b6e5ca..d0d55f46da 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c @@ -445,10 +445,12 @@ WifiMgrRefreshNetworkList ( UnicodeSPrint (PortString, PortStringSize, L"AKMSuite: %s CipherSuite: %s", AKMListDisplay, CipherListDisplay); PortHelpToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL); } FreePool (AKMListDisplay); FreePool (CipherListDisplay); + AKMListDisplay = NULL; + CipherListDisplay = NULL; HiiCreateGotoOpCode ( StartOpCodeHandle, FORMID_CONNECT_NETWORK, PortPromptToken, @@ -530,10 +532,12 @@ WifiMgrRefreshNetworkList ( goto Exit; } } FreePool (AKMListDisplay); FreePool (CipherListDisplay); + AKMListDisplay = NULL; + CipherListDisplay = NULL; HiiCreateGotoOpCode ( StartOpCodeHandle, FORMID_CONNECT_NETWORK, PortPromptToken, @@ -610,10 +614,12 @@ WifiMgrRefreshNetworkList ( AKMListDisplay, CipherListDisplay ); } FreePool (AKMListDisplay); FreePool (CipherListDisplay); + AKMListDisplay = NULL; + CipherListDisplay = NULL; PortHelpToken = HiiSetString (Private->RegisteredHandle, 0, PortString, NULL); HiiCreateGotoOpCode ( StartOpCodeHandle, @@ -1655,10 +1661,11 @@ WifiMgrDxeHiiConfigAccessCallback ( Profile = Private->CurrentNic->UserSelectedProfile; if (Profile->PrivateKeyData != NULL) { ZeroMem (Profile->PrivateKeyData, Profile->PrivateKeyDataSize); FreePool (Profile->PrivateKeyData); + Profile->PrivateKeyData = NULL; } Status = WifiMgrReadFileToBuffer ( Private->FileContext, &TempData, @@ -1698,16 +1705,18 @@ WifiMgrDxeHiiConfigAccessCallback ( if (Private->FileType == FileTypeCACert) { if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); + Profile->CACertData = NULL; } } else if (Private->FileType == FileTypeClientCert) { if (Profile->ClientCertData != NULL) { ZeroMem (Profile->ClientCertData, Profile->ClientCertSize); FreePool (Profile->ClientCertData); + Profile->ClientCertData = NULL; } } else { break; } diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 52ce18dfd8..9417440ac5 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -210,11 +210,10 @@ WifiMgrOnScanFinished ( } continue; } } - FreePool (Result); gBS->SignalEvent (Nic->Private->NetworkListRefreshEvent); // // The current connected network should always be available until disconnection // happens in Wifi FW layer, even when it is not in this time's scan result. -- 2.16.2.windows.1