]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue
authorjdzhang <jdzhang@zd-tech.com.cn>
Thu, 25 Nov 2021 07:44:48 +0000 (15:44 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 9 Dec 2021 02:36:30 +0000 (02:36 +0000)
When use the UsbHcAllocMemFromBlock() and UsbHcFreeMem() to allocate
memory and free memory for the UHC, it should use the corresponding host
address but not the pci bus address.

Signed-off-by: jdzhang <jdzhang@zd-tech.com.cn>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c

index d6b9615e499264a4d9430627e1d072cec427f2cc..c3d46f60bed50be167e3db91b13cba0a0f6f091b 100644 (file)
@@ -207,7 +207,7 @@ UsbHcAllocMemFromBlock (
     NEXT_BIT (Byte, Bit);\r
   }\r
 \r
-  return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;\r
+  return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT;\r
 }\r
 \r
 /**\r
@@ -508,12 +508,12 @@ UsbHcFreeMem (
     // scan the memory block list for the memory block that\r
     // completely contains the memory to free.\r
     //\r
-    if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) {\r
+    if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) {\r
       //\r
       // compute the start byte and bit in the bit array\r
       //\r
-      Byte = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8;\r
-      Bit  = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8;\r
+      Byte = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8;\r
+      Bit  = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8;\r
 \r
       //\r
       // reset associated bits in bit array\r