X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FUndiRuntimeDxe%2FInit.c;h=413ef32a7a8b5f76eb529da8b1636a9c7c6bc8da;hp=b79c5fe7a676f91a632f5f95ff25e4dc3170b675;hb=6a6d955c5f670141344c614c65dbea332f393b57;hpb=ac4f8b5abe6758183102be3feea30c7430eedf3a;ds=sidebyside diff --git a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c index b79c5fe7a6..413ef32a7a 100644 --- a/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c +++ b/MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c @@ -287,6 +287,7 @@ Returns: EFI_PCI_IO_PROTOCOL *PciIoFncs; UINTN Len; UINT64 Supports; + BOOLEAN PciAttributesSaved; Status = gBS->OpenProtocol ( Controller, @@ -321,6 +322,8 @@ Returns: return Status; } + PciAttributesSaved = FALSE; + Status = gBS->AllocatePool ( EfiRuntimeServicesData, sizeof (UNDI32_DEV), @@ -344,8 +347,9 @@ Returns: ); if (EFI_ERROR (Status)) { - return Status; + goto UndiErrorDeleteDevice; } + PciAttributesSaved = TRUE; // // allocate and initialize both (old and new) the !pxe structures here, @@ -550,15 +554,17 @@ UndiErrorDeletePxe: } UndiErrorDeleteDevice: - // - // Restore original PCI attributes - // - PciIoFncs->Attributes ( - PciIoFncs, - EfiPciIoAttributeOperationSet, - UNDI32Device->NicInfo.OriginalPciAttributes, - NULL - ); + if (PciAttributesSaved == TRUE) { + // + // Restore original PCI attributes + // + PciIoFncs->Attributes ( + PciIoFncs, + EfiPciIoAttributeOperationSet, + UNDI32Device->NicInfo.OriginalPciAttributes, + NULL + ); + } gBS->FreePool (UNDI32Device);