From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E23B781D65 for ; Thu, 3 Nov 2016 18:35:11 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Nov 2016 18:35:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,589,1473145200"; d="scan'208";a="1054940067" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 03 Nov 2016 18:35:13 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Nov 2016 18:35:13 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Nov 2016 18:34:12 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.139]) with mapi id 14.03.0248.002; Fri, 4 Nov 2016 09:34:10 +0800 From: "Zeng, Star" To: "Marvin.Haeuser@outlook.com" , "edk2-devel@lists.01.org" CC: "Tian, Feng" , "Zeng, Star" Thread-Topic: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices (). Thread-Index: AQHSNidtNdv9Y2VlQE+ywGajW/iMv6DICr1A Date: Fri, 4 Nov 2016 01:34:09 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB04831039596200@shsmsx102.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Fri, 04 Nov 2016 01:35:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com]=20 Sent: Friday, November 4, 2016 7:10 AM To: edk2-devel@lists.01.org Cc: Tian, Feng ; Zeng, Star Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootSer= vices (). During exiting Boot Services, there should be no changes made to the Memory= Map. This patch eliminates explicit and implicit calls to the Memory Alloc= ation 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