public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marvin Häuser" <Marvin.Haeuser@outlook.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "feng.tian@intel.com" <feng.tian@intel.com>,
	"star.zeng@intel.com" <star.zeng@intel.com>
Subject: [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices ().
Date: Thu, 3 Nov 2016 23:10:11 +0000	[thread overview]
Message-ID: <AM5PR0601MB2579397BD944B631DB24F79080A30@AM5PR0601MB2579.eurprd06.prod.outlook.com> (raw)

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 <Marvin.Haeuser@outlook.com>
---
 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/MdeModulePkg/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;
 
   Private = (ISCSI_DRIVER_DATA *) Context;
-  gBS->CloseEvent (Private->ExitBootServiceEvent);
 
-  IScsiSessionAbort (&Private->Session);
+  if (Private->Session.Signature != 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));
+  }
 }
 
 /**
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/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 (
 
   Snp  = (SNP_DRIVER *)Context;
 
+  if (Snp->TxRxBuffer != 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 = NULL;
+  }
+
   //
   // Shutdown and stop UNDI driver
   //
-- 
2.10.1.windows.1



             reply	other threads:[~2016-11-03 23:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03 23:10 Marvin Häuser [this message]
2016-11-04  1:34 ` [PATCH v2 1/2] MdeModulePkg: Do not free memory during ExitBootServices () Zeng, Star
2016-11-05 16:48   ` Marvin Häuser
2016-11-07  1:08 ` Tian, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM5PR0601MB2579397BD944B631DB24F79080A30@AM5PR0601MB2579.eurprd06.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox