diff --git a/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.c b/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.c index 4ce5c959..70119384 100644 --- a/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.c +++ b/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.c @@ -1509,17 +1509,21 @@ OcAppleBootPolicyInstallProtocol ( EFI_HANDLE Handle; if (Reinstall) { - UninstallAllProtocolInstances (&gAppleBootPolicyProtocolGuid); - } + Status = UninstallAllProtocolInstances (&gAppleBootPolicyProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "OCBP: Uninstall failed: %r\n", Status)); + return NULL; + } + } else { + Status = gBS->LocateProtocol ( + &gAppleBootPolicyProtocolGuid, + NULL, + (VOID *) &Protocol + ); - Status = gBS->LocateProtocol ( - &gAppleBootPolicyProtocolGuid, - NULL, - (VOID *) &Protocol - ); - - if (!EFI_ERROR (Status)) { - return Protocol; + if (!EFI_ERROR (Status)) { + return Protocol; + } } Handle = NULL; diff --git a/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.c b/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.c index 21065813..6b54f940 100644 --- a/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.c +++ b/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.c @@ -604,7 +604,7 @@ InternalVerifyImg4ByPathWorker ( STATIC CONST UINTN ManifestSuffixMaxSize = (((ARRAY_SIZE (HwModel) - 1 + (2 * sizeof (Ecid))) * sizeof (CHAR16)) - + L_STR_SIZE (L"...im4m")); + + L_STR_SIZE_NT (L"...im4m")); Status = gBS->LocateDevicePath ( &gEfiSimpleFileSystemProtocolGuid, @@ -1011,16 +1011,20 @@ OcAppleSecureBootInstallProtocol ( EFI_HANDLE Handle; if (Reinstall) { - UninstallAllProtocolInstances (&gAppleSecureBootProtocolGuid); - } - - Status = gBS->LocateProtocol ( - &gAppleSecureBootProtocolGuid, - NULL, - (VOID **)&Protocol - ); - if (!EFI_ERROR (Status)) { - return Protocol; + Status = UninstallAllProtocolInstances (&gAppleSecureBootProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "OCSB: Uninstall failed: %r\n", Status)); + return NULL; + } + } else { + Status = gBS->LocateProtocol ( + &gAppleSecureBootProtocolGuid, + NULL, + (VOID **)&Protocol + ); + if (!EFI_ERROR (Status)) { + return Protocol; + } } Handle = NULL; diff --git a/Library/OcDataHubLib/OcDataHubLib.c b/Library/OcDataHubLib/OcDataHubLib.c index ed10046e..2471b84c 100755 --- a/Library/OcDataHubLib/OcDataHubLib.c +++ b/Library/OcDataHubLib/OcDataHubLib.c @@ -52,21 +52,24 @@ OcDataHubInstallProtocol ( EFI_DATA_HUB_PROTOCOL *DataHub; if (Reinstall) { - UninstallAllProtocolInstances (&gEfiDataHubProtocolGuid); + Status = UninstallAllProtocolInstances (&gEfiDataHubProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "OCDH: Uninstall failed: %r\n", Status)); + return NULL; + } + } else { + Status = gBS->LocateProtocol ( + &gEfiDataHubProtocolGuid, + NULL, + (VOID **) &DataHub + ); + + if (!EFI_ERROR (Status)) { + return DataHub; + } } - DataHub = NULL; - Status = gBS->LocateProtocol ( - &gEfiDataHubProtocolGuid, - NULL, - (VOID **) &DataHub - ); - - if (EFI_ERROR (Status)) { - return DataHubInstall (); - } - - return DataHub; + return DataHubInstall (); } STATIC diff --git a/Library/OcDevicePropertyLib/OcDevicePropertyLib.c b/Library/OcDevicePropertyLib/OcDevicePropertyLib.c index 242f5041..9d54412a 100755 --- a/Library/OcDevicePropertyLib/OcDevicePropertyLib.c +++ b/Library/OcDevicePropertyLib/OcDevicePropertyLib.c @@ -796,17 +796,21 @@ OcDevicePathPropertyInstallProtocol ( EFI_HANDLE Handle; if (Reinstall) { - UninstallAllProtocolInstances (&gEfiDevicePathPropertyDatabaseProtocolGuid); - } + Status = UninstallAllProtocolInstances (&gEfiDevicePathPropertyDatabaseProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "OCDP: Uninstall failed: %r\n", Status)); + return NULL; + } + } else { + Status = gBS->LocateProtocol ( + &gEfiDevicePathPropertyDatabaseProtocolGuid, + NULL, + (VOID *)&Protocol + ); - Status = gBS->LocateProtocol ( - &gEfiDevicePathPropertyDatabaseProtocolGuid, - NULL, - (VOID *)&Protocol - ); - - if (!EFI_ERROR (Status)) { - return Protocol; + if (!EFI_ERROR (Status)) { + return Protocol; + } } DevicePathPropertyData = AllocateZeroPool (sizeof (*DevicePathPropertyData));