[edk2-devel] [PATCH] MdeModulePkg XhciPei: Fix dead loop issue in UsbHcFreeMemPool()

Zeng, Star posted 1 patch 1 year, 8 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH] MdeModulePkg XhciPei: Fix dead loop issue in UsbHcFreeMemPool()
Posted by Zeng, Star 1 year, 8 months ago
Use Block->Next instead of Pool->Head->Next, otherwise the for loop
will be not able to come out.
It will also match with the UsbHcFreeMemPool() in EhciPei.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhikai Sun <zhikai.sun@intel.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
index c64b38fcfc89..148425ae844e 100644
--- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
@@ -385,7 +385,7 @@ UsbHcFreeMemPool (
   // UsbHcUnlinkMemBlock can't be used to unlink and free the
   // first block.
   //
-  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
+  for (Block = Pool->Head->Next; Block != NULL; Block = Block->Next) {
     // UsbHcUnlinkMemBlock (Pool->Head, Block);
     UsbHcFreeMemBlock (Pool, Block);
   }
-- 
2.33.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92165): https://edk2.groups.io/g/devel/message/92165
Mute This Topic: https://groups.io/mt/92833071/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] MdeModulePkg XhciPei: Fix dead loop issue in UsbHcFreeMemPool()
Posted by Wu, Hao A 1 year, 8 months ago
Thanks Star,

How about removing the comments that mention 'UsbHcUnlinkMemBlock' (3 occurrences, in UsbHcFreeMemPool() and UsbHcFreeMem()) to avoid possible confusion?

Best Regards,
Hao Wu

> -----Original Message-----
> From: Zeng, Star <star.zeng@intel.com>
> Sent: Friday, August 5, 2022 7:44 PM
> To: devel@edk2.groups.io
> Cc: Zeng, Star <star.zeng@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Ni,
> Ray <ray.ni@intel.com>; Sun, Zhikai <zhikai.sun@intel.com>
> Subject: [PATCH] MdeModulePkg XhciPei: Fix dead loop issue in
> UsbHcFreeMemPool()
> 
> Use Block->Next instead of Pool->Head->Next, otherwise the for loop will be
> not able to come out.
> It will also match with the UsbHcFreeMemPool() in EhciPei.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhikai Sun <zhikai.sun@intel.com>
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> index c64b38fcfc89..148425ae844e 100644
> --- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> +++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> @@ -385,7 +385,7 @@ UsbHcFreeMemPool (
>    // UsbHcUnlinkMemBlock can't be used to unlink and free the   // first block.
> //-  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next)
> {+  for (Block = Pool->Head->Next; Block != NULL; Block = Block->Next) {     //
> UsbHcUnlinkMemBlock (Pool->Head, Block);     UsbHcFreeMemBlock (Pool,
> Block);   }--
> 2.33.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92186): https://edk2.groups.io/g/devel/message/92186
Mute This Topic: https://groups.io/mt/92833071/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-