public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner" <abner.chang@amd.com>
To: <devel@edk2.groups.io>
Cc: <Kuei-Hung.Lin@amd.com>, Hao A Wu <hao.a.wu@intel.com>,
	Ray Ni <ray.ni@intel.com>,
	Garrett Kirkendall <garrett.kirkendall@amd.com>,
	"Abner Chang" <abner.chang@amd.com>
Subject: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
Date: Sat, 10 Dec 2022 23:12:40 +0800	[thread overview]
Message-ID: <20221210151240.1548-1-abner.chang@amd.com> (raw)

From: Abner Chang <abner.chang@amd.com>

In V2: Add AMD copyright.

Unlink the XhciPei memory block when it has been freed.

Signed-off-by: Kuei-Hung Lin <Kuei-Hung.Lin@amd.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
---
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 29 ++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
index c64b38fcfc8..39ba31b0913 100644
--- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
@@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid
 which is used to enable recovery function from USB Drivers.
 
 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -365,6 +366,32 @@ UsbHcInitMemPool (
   return Pool;
 }
 
+/**
+  Unlink the memory block from the pool's list.
+
+  @param  Head           The block list head of the memory's pool.
+  @param  BlockToUnlink  The memory block to unlink.
+
+**/
+VOID
+UsbHcUnlinkMemBlock (
+  IN USBHC_MEM_BLOCK  *Head,
+  IN USBHC_MEM_BLOCK  *BlockToUnlink
+  )
+{
+  USBHC_MEM_BLOCK  *Block;
+
+  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
+
+  for (Block = Head; Block != NULL; Block = Block->Next) {
+    if (Block->Next == BlockToUnlink) {
+      Block->Next         = BlockToUnlink->Next;
+      BlockToUnlink->Next = NULL;
+      break;
+    }
+  }
+}
+
 /**
   Release the memory management pool.
 
@@ -386,8 +413,8 @@ UsbHcFreeMemPool (
   // first block.
   //
   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
-    // UsbHcUnlinkMemBlock (Pool->Head, Block);
     UsbHcFreeMemBlock (Pool, Block);
+    UsbHcUnlinkMemBlock (Pool->Head, Block);
   }
 
   UsbHcFreeMemBlock (Pool, Pool->Head);
-- 
2.37.1.windows.1


             reply	other threads:[~2022-12-10 15:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10 15:12 Chang, Abner [this message]
2022-12-12  3:27 ` [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block Wu, Hao A
2022-12-15  2:11   ` Chang, Abner
2022-12-15 16:47     ` He, Jiangang
2022-12-19  6:40       ` Wu, Hao A
2022-12-19 22:53         ` He, Jiangang
2022-12-20  0:26           ` Wu, Hao A
2022-12-20  0:27             ` Chang, Abner

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=20221210151240.1548-1-abner.chang@amd.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