@@ -65,7 +65,10 @@ PatchAppleCpuPmCfgLock (
6565 return EFI_SUCCESS ;
6666 }
6767
68- ASSERT (Patcher != NULL );
68+ if (Patcher == NULL ) {
69+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
70+ return EFI_NOT_FOUND ;
71+ }
6972
7073 Count = 0 ;
7174 Walker = (UINT8 * )MachoGetMachHeader (& Patcher -> MachContext );
@@ -648,6 +651,11 @@ PatchUsbXhciPortLimit1 (
648651 return EFI_SUCCESS ;
649652 }
650653
654+ if (Patcher == NULL ) {
655+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
656+ return EFI_NOT_FOUND ;
657+ }
658+
651659 Status = PatcherApplyGenericPatch (Patcher , & mRemoveUsbLimitIoP1Patch );
652660 if (EFI_ERROR (Status )) {
653661 DEBUG ((DEBUG_INFO , "OCAK: Failed to apply port patch com.apple.iokit.IOUSBHostFamily - %r\n" , Status ));
@@ -667,13 +675,16 @@ PatchUsbXhciPortLimit2 (
667675{
668676 EFI_STATUS Status ;
669677
670- ASSERT (Patcher != NULL );
671-
672678 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_HIGH_SIERRA_MIN , 0 )) {
673679 DEBUG ((DEBUG_INFO , "OCAK: Skipping modern port patch AppleUSBXHCI on %u\n" , KernelVersion ));
674680 return EFI_SUCCESS ;
675681 }
676682
683+ if (Patcher == NULL ) {
684+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
685+ return EFI_NOT_FOUND ;
686+ }
687+
677688 //
678689 // TODO: Implement some locationID hack in IOUSBHostFamily.
679690 // The location ID is a 32 bit number which is unique among all USB devices in the system,
@@ -728,13 +739,16 @@ PatchUsbXhciPortLimit3 (
728739{
729740 EFI_STATUS Status ;
730741
731- ASSERT (Patcher != NULL );
732-
733742 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_EL_CAPITAN_MIN , KERNEL_VERSION_HIGH_SIERRA_MAX )) {
734743 DEBUG ((DEBUG_INFO , "OCAK: Skipping legacy port patch AppleUSBXHCIPCI on %u\n" , KernelVersion ));
735744 return EFI_SUCCESS ;
736745 }
737746
747+ if (Patcher == NULL ) {
748+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
749+ return EFI_NOT_FOUND ;
750+ }
751+
738752 //
739753 // If we are here, we are on legacy 10.13 or below, try the oldest patch.
740754 //
@@ -819,7 +833,10 @@ PatchThirdPartyDriveSupport (
819833{
820834 EFI_STATUS Status ;
821835
822- ASSERT (Patcher != NULL );
836+ if (Patcher == NULL ) {
837+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
838+ return EFI_NOT_FOUND ;
839+ }
823840
824841 Status = PatcherApplyGenericPatch (Patcher , & mIOAHCIBlockStoragePatchV1 );
825842 if (EFI_ERROR (Status )) {
@@ -888,7 +905,10 @@ PatchForceInternalDiskIcons (
888905{
889906 EFI_STATUS Status ;
890907
891- ASSERT (Patcher != NULL );
908+ if (Patcher == NULL ) {
909+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
910+ return EFI_NOT_FOUND ;
911+ }
892912
893913 Status = PatcherApplyGenericPatch (Patcher , & mIOAHCIPortPatch );
894914 if (EFI_ERROR (Status )) {
@@ -935,13 +955,16 @@ PatchAppleIoMapperSupport (
935955{
936956 EFI_STATUS Status ;
937957
938- ASSERT (Patcher != NULL );
939-
940958 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_MOUNTAIN_LION_MIN , 0 )) {
941959 DEBUG ((DEBUG_INFO , "OCAK: Skipping AppleIoMapper patch on %u\n" , KernelVersion ));
942960 return EFI_SUCCESS ;
943961 }
944962
963+ if (Patcher == NULL ) {
964+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
965+ return EFI_NOT_FOUND ;
966+ }
967+
945968 Status = PatcherApplyGenericPatch (Patcher , & mAppleIoMapperPatch );
946969 if (EFI_ERROR (Status )) {
947970 DEBUG ((DEBUG_INFO , "OCAK: Failed to apply patch com.apple.iokit.IOPCIFamily AppleIoMapper - %r\n" , Status ));
@@ -987,7 +1010,10 @@ PatchDummyPowerManagement (
9871010 return EFI_SUCCESS ;
9881011 }
9891012
990- ASSERT (Patcher != NULL );
1013+ if (Patcher == NULL ) {
1014+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
1015+ return EFI_NOT_FOUND ;
1016+ }
9911017
9921018 Status = PatcherApplyGenericPatch (Patcher , & mAppleDummyCpuPmPatch );
9931019 if (EFI_ERROR (Status )) {
@@ -1062,13 +1088,16 @@ PatchIncreasePciBarSize (
10621088{
10631089 EFI_STATUS Status ;
10641090
1065- ASSERT (Patcher != NULL );
1066-
10671091 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_YOSEMITE_MIN , 0 )) {
10681092 DEBUG ((DEBUG_INFO , "OCAK: Skipping com.apple.iokit.IOPCIFamily IncreasePciBarSize on %u\n" , KernelVersion ));
10691093 return EFI_SUCCESS ;
10701094 }
10711095
1096+ if (Patcher == NULL ) {
1097+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
1098+ return EFI_NOT_FOUND ;
1099+ }
1100+
10721101 Status = PatcherApplyGenericPatch (Patcher , & mIncreasePciBarSizePatch );
10731102 if (EFI_ERROR (Status )) {
10741103 DEBUG ((DEBUG_INFO , "OCAK: Failed to apply patch com.apple.iokit.IOPCIFamily IncreasePciBarSize - %r, trying legacy patch\n" , Status ));
@@ -1271,7 +1300,10 @@ PatchCustomSmbiosGuid (
12711300{
12721301 EFI_STATUS Status ;
12731302
1274- ASSERT (Patcher != NULL );
1303+ if (Patcher == NULL ) {
1304+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
1305+ return EFI_NOT_FOUND ;
1306+ }
12751307
12761308 Status = PatcherApplyGenericPatch (Patcher , & mCustomSmbiosGuidPatch );
12771309 if (!EFI_ERROR (Status )) {
@@ -1705,7 +1737,10 @@ PatchAppleRtcChecksum (
17051737{
17061738 EFI_STATUS Status ;
17071739
1708- ASSERT (Patcher != NULL );
1740+ if (Patcher == NULL ) {
1741+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
1742+ return EFI_NOT_FOUND ;
1743+ }
17091744
17101745 Status = PatcherApplyGenericPatch (Patcher , Patcher -> Is32Bit ? & mAppleRtcChecksumPatch32 : & mAppleRtcChecksumPatch64 );
17111746 if (EFI_ERROR (Status )) {
@@ -1866,13 +1901,16 @@ PatchBTFeatureFlags (
18661901{
18671902 EFI_STATUS Status ;
18681903
1869- ASSERT (Patcher != NULL );
1870-
18711904 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_MOUNTAIN_LION_MIN , 0 )) {
18721905 DEBUG ((DEBUG_INFO , "OCAK: Skipping BTFeatureFlags on %u\n" , KernelVersion ));
18731906 return EFI_SUCCESS ;
18741907 }
18751908
1909+ if (Patcher == NULL ) {
1910+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
1911+ return EFI_NOT_FOUND ;
1912+ }
1913+
18761914 Status = PatcherApplyGenericPatch (Patcher , & mBTFeatureFlagsPatchV1 );
18771915 if (EFI_ERROR (Status )) {
18781916 DEBUG ((DEBUG_INFO , "OCAK: Failed to find BT FeatureFlags symbol v1 - %r, trying v2\n" , Status ));
@@ -2141,8 +2179,6 @@ PatchAquantiaEthernet (
21412179{
21422180 EFI_STATUS Status ;
21432181
2144- ASSERT (Patcher != NULL );
2145-
21462182 //
21472183 // This patch is not required before macOS 10.15.4.
21482184 //
@@ -2151,6 +2187,11 @@ PatchAquantiaEthernet (
21512187 return EFI_SUCCESS ;
21522188 }
21532189
2190+ if (Patcher == NULL ) {
2191+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
2192+ return EFI_NOT_FOUND ;
2193+ }
2194+
21542195 //
21552196 // Shikumo's patch can be applied to a wider range, not limited to AQC 107 series,
21562197 // thus preferred.
@@ -2188,13 +2229,16 @@ PatchForceSecureBootScheme (
21882229 UINT8 * HybridAp ;
21892230 UINT32 Diff ;
21902231
2191- ASSERT (Patcher != NULL );
2192-
21932232 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_BIG_SUR_MIN , 0 )) {
21942233 DEBUG ((DEBUG_INFO , "OCAK: Skipping sb scheme on %u\n" , KernelVersion ));
21952234 return EFI_SUCCESS ;
21962235 }
21972236
2237+ if (Patcher == NULL ) {
2238+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
2239+ return EFI_NOT_FOUND ;
2240+ }
2241+
21982242 //
21992243 // This code is for debugging APFS snapshot verification for Big Sur.
22002244 // macOS chooses verification scheme based on the hardware:
@@ -2308,13 +2352,16 @@ PatchSetApfsTrimTimeout (
23082352{
23092353 EFI_STATUS Status ;
23102354
2311- ASSERT (Patcher != NULL );
2312-
23132355 if (!OcMatchDarwinVersion (KernelVersion , KERNEL_VERSION_MOJAVE_MIN , 0 )) {
23142356 DEBUG ((DEBUG_INFO , "OCAK: Skipping apfs timeout on %u\n" , KernelVersion ));
23152357 return EFI_SUCCESS ;
23162358 }
23172359
2360+ if (Patcher == NULL ) {
2361+ DEBUG ((DEBUG_INFO , "OCAK: Skipping %a on NULL Patcher on %u\n" , __func__ , KernelVersion ));
2362+ return EFI_NOT_FOUND ;
2363+ }
2364+
23182365 //
23192366 // Disable trim using another patch when timeout is 0.
23202367 //
0 commit comments