From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from BAY004-OMC3S17.hotmail.com (bay004-omc3s17.hotmail.com [65.54.190.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9967581C8B for ; Thu, 3 Nov 2016 16:10:12 -0700 (PDT) Received: from EUR01-DB5-obe.outbound.protection.outlook.com ([65.54.190.188]) by BAY004-OMC3S17.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Thu, 3 Nov 2016 16:10:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hL832yA3MwcBU48UgSssSKV7u1DtBKkjONNWyPY0wuM=; b=nyb86/bMGN79aZYvqi3hCGncgLwP3FWswLGB8+aZtTIw5l26X0c/QK9teXncMF6kCs62N2n8BjV/rno5XiYXZiEIN+LIuaRu+PIp0vrp5Glr8PcRV9vSx+sjPsavl6Q7Xp1CRDfYHW27B7/TqSw1IBRY2RkD8/t9DF610W0Cpyc8FiKJ76IhUDrekOqcHcKvaTFccpAqWG17uc+EPbtbOYjEzCECIC70thrLzETa2FcO1634esppl3b4MChrqLxYIU97UWoSLANp8i9/p7GiIkR1e9v5o3W/0FlbKeEmysappZ/V2WMudtaSzr4mQs6LRltZIARJBOdC77kzw6Ufcw== Received: from VE1EUR01FT028.eop-EUR01.prod.protection.outlook.com (10.152.2.60) by VE1EUR01HT165.eop-EUR01.prod.protection.outlook.com (10.152.3.249) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6; Thu, 3 Nov 2016 23:10:12 +0000 Received: from AM5PR0601MB2579.eurprd06.prod.outlook.com (10.152.2.56) by VE1EUR01FT028.mail.protection.outlook.com (10.152.2.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.6 via Frontend Transport; Thu, 3 Nov 2016 23:10:12 +0000 Received: from AM5PR0601MB2579.eurprd06.prod.outlook.com ([10.168.154.13]) by AM5PR0601MB2579.eurprd06.prod.outlook.com ([10.168.154.13]) with mapi id 15.01.0693.016; Thu, 3 Nov 2016 23:10:12 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: "feng.tian@intel.com" , "star.zeng@intel.com" Thread-Topic: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices (). Thread-Index: AQHSNidtNdv9Y2VlQE+ywGajW/iMvw== Date: Thu, 3 Nov 2016 23:10:11 +0000 Message-ID: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=outlook.com; x-incomingtopheadermarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:7130; Count:34 x-ms-exchange-messagesentrepresentingtype: 1 x-incomingheadercount: 34 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; VE1EUR01HT165; 7:Y1drNwO8RVRtABgWmRYJued6Cuyy3Rt+M3Fg9n3qtdnjwfmzs0FHfapjKWBla9OegRtkb7Zejy5wBSzZH6q7s7om3+x86N5UxTRKdF5vCfw+JHaQfmnS43ZwH1uEgFwFp1X4tl6oUnsCJ/RJbbjJqzJJ8gwsYkqSLQAMs7q9xJ3o7w/oHO/bFUVTaxSl+8Ee1maAL/nAJ6Ok5sEklWKUEAYi46e+UmbFwJiCIk5AeuCDFApMKLNQhHSmXBEhqw2pjYXx702E+xKO463fpnav/y1+jEkDYs7aBcI2zX8qFa+55qd0+nSxtBZuLMm5p6f975HnuIXbJnf2MrZyusir9pv7AycK1k7uHe/1DZXEE5w= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:VE1EUR01HT165; H:AM5PR0601MB2579.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 325e2147-a7a5-4fce-ff36-08d4043e8f80 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1603103107)(1601125047); SRVR:VE1EUR01HT165; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(82015046); SRVR:VE1EUR01HT165; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR01HT165; x-forefront-prvs: 011579F31F spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Nov 2016 23:10:11.8070 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT165 X-OriginalArrivalTime: 03 Nov 2016 23:10:14.0292 (UTC) FILETIME=[6F1C5D40:01D23627] Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices (). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 23:10:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable During exiting Boot Services, there should be no changes made to the Memory Map. This patch eliminates explicit and implicit calls to the Memory Allocation Services and, where applicable, zeros the memory instead. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marvin Haeuser --- MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 11 +++++++++-- MdeModulePkg/Universal/Network/SnpDxe/Snp.c | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModul= ePkg/Universal/Network/IScsiDxe/IScsiMisc.c index ae202c3fe24a..b5e36b8bec06 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -872,9 +872,16 @@ IScsiOnExitBootService ( ISCSI_DRIVER_DATA *Private; =20 Private =3D (ISCSI_DRIVER_DATA *) Context; - gBS->CloseEvent (Private->ExitBootServiceEvent); =20 - IScsiSessionAbort (&Private->Session); + if (Private->Session.Signature !=3D 0) { + IScsiSessionAbort (&Private->Session); + + // + // Empty Session as it will not be freed. + // This will also prevent this code from being re-run. + // + ZeroMem (&Private->Session, sizeof (Private->Session)); + } } =20 /** diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Uni= versal/Network/SnpDxe/Snp.c index 9f61aee05773..e15e79c7065f 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c @@ -32,6 +32,18 @@ SnpNotifyExitBootServices ( =20 Snp =3D (SNP_DRIVER *)Context; =20 + if (Snp->TxRxBuffer !=3D NULL) { + // + // Empty TxRxBuffer as it will not be freed. + // + ZeroMem (Snp->TxRxBuffer, Snp->TxRxBufferSize); + + // + // Set TxRxBuffer to NULL so FreeBuffer () will not be called. + // + Snp->TxRxBuffer =3D NULL; + } + // // Shutdown and stop UNDI driver // --=20 2.10.1.windows.1