return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- *Mapping = Map;\r
-\r
if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) ||\r
((*NumberOfBytes & (gCacheAlignment - 1)) != 0)) {\r
\r
// Get the cacheability of the region\r
Status = gDS->GetMemorySpaceDescriptor (*DeviceAddress, &GcdDescriptor);\r
if (EFI_ERROR(Status)) {\r
- return Status;\r
+ goto FreeMapInfo;\r
}\r
\r
// If the mapped buffer is not an uncached buffer\r
"%a: Operation type 'MapOperationBusMasterCommonBuffer' is only supported\n"\r
"on memory regions that were allocated using DmaAllocateBuffer ()\n",\r
__FUNCTION__));\r
- return EFI_UNSUPPORTED;\r
+ Status = EFI_UNSUPPORTED;\r
+ goto FreeMapInfo;\r
}\r
\r
//\r
Map->DoubleBuffer = TRUE;\r
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto FreeMapInfo;\r
}\r
\r
if (Operation == MapOperationBusMasterRead) {\r
Map->NumberOfBytes = *NumberOfBytes;\r
Map->Operation = Operation;\r
\r
+ *Mapping = Map;\r
+\r
return EFI_SUCCESS;\r
+\r
+FreeMapInfo:\r
+ FreePool (Map);\r
+\r
+ return Status;\r
}\r
\r
\r