From d25b803e514a11a25de91d4174b289d2ae783338 Mon Sep 17 00:00:00 2001 From: jdzhang Date: Thu, 25 Nov 2021 15:44:48 +0800 Subject: MdeModulePkg/Bus/Pci/UhciDxe: Fix the UsbHc memory allocate and free issue 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 Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c index d6b9615e49..c3d46f60be 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c @@ -207,7 +207,7 @@ UsbHcAllocMemFromBlock ( NEXT_BIT (Byte, Bit); } - return Block->Buf + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT; + return Block->BufHost + (StartByte * 8 + StartBit) * USBHC_MEM_UNIT; } /** @@ -508,12 +508,12 @@ UsbHcFreeMem ( // scan the memory block list for the memory block that // completely contains the memory to free. // - if ((Block->Buf <= ToFree) && ((ToFree + AllocSize) <= (Block->Buf + Block->BufLen))) { + if ((Block->BufHost <= ToFree) && ((ToFree + AllocSize) <= (Block->BufHost + Block->BufLen))) { // // compute the start byte and bit in the bit array // - Byte = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) / 8; - Bit = ((ToFree - Block->Buf) / USBHC_MEM_UNIT) % 8; + Byte = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) / 8; + Bit = ((ToFree - Block->BufHost) / USBHC_MEM_UNIT) % 8; // // reset associated bits in bit array -- cgit v1.2.3