VirtualBox

Ignore:
Timestamp:
Mar 31, 2025 11:31:09 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168237
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

    r99404 r108794  
    270270  // skip preceeding white space
    271271  //
    272   while ((*Str != 0) && *Str == L' ') {
     272  while (*Str == L' ') {
    273273    Str++;
    274274  }
     
    277277  // skip preceeding zeros
    278278  //
    279   while ((*Str != 0) && *Str == L'0') {
     279  while (*Str == L'0') {
    280280    Str++;
    281281  }
     
    389389           );
    390390
    391   StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength);
     391  if (Node != NULL) {
     392    StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength);
     393  }
     394
    392395  return Node;
    393396}
     
    454457                                     );
    455458
    456   Pci->Function = (UINT8)Strtoi (FunctionStr);
    457   Pci->Device   = (UINT8)Strtoi (DeviceStr);
     459  if (Pci != NULL) {
     460    Pci->Function = (UINT8)Strtoi (FunctionStr);
     461    Pci->Device   = (UINT8)Strtoi (DeviceStr);
     462  }
    458463
    459464  return (EFI_DEVICE_PATH_PROTOCOL *)Pci;
     
    483488                                              );
    484489
    485   Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr);
     490  if (Pccard != NULL) {
     491    Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr);
     492  }
    486493
    487494  return (EFI_DEVICE_PATH_PROTOCOL *)Pccard;
     
    515522                                               );
    516523
    517   MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr);
    518   Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
    519   Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
     524  if (MemMap != NULL) {
     525    MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr);
     526    Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
     527    Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
     528  }
    520529
    521530  return (EFI_DEVICE_PATH_PROTOCOL *)MemMap;
     
    560569                                   );
    561570
    562   StrToGuid (GuidStr, &Vendor->Guid);
    563   StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length);
     571  if (Vendor != NULL) {
     572    StrToGuid (GuidStr, &Vendor->Guid);
     573    StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length);
     574  }
    564575
    565576  return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
     
    608619                                              (UINT16)sizeof (CONTROLLER_DEVICE_PATH)
    609620                                              );
    610   Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr);
     621
     622  if (Controller != NULL) {
     623    Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr);
     624  }
    611625
    612626  return (EFI_DEVICE_PATH_PROTOCOL *)Controller;
     
    638652                                          );
    639653
    640   BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr);
    641   WriteUnaligned64 (
    642     (UINT64 *)(&BmcDp->BaseAddress),
    643     StrHexToUint64 (BaseAddressStr)
    644     );
     654  if (BmcDp != NULL) {
     655    BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr);
     656    WriteUnaligned64 (
     657      (UINT64 *)(&BmcDp->BaseAddress),
     658      StrHexToUint64 (BaseAddressStr)
     659      );
     660  }
    645661
    646662  return (EFI_DEVICE_PATH_PROTOCOL *)BmcDp;
     
    707723                                     );
    708724
    709   Acpi->HID = EisaIdFromText (HIDStr);
    710   Acpi->UID = (UINT32)Strtoi (UIDStr);
     725  if (Acpi != NULL) {
     726    Acpi->HID = EisaIdFromText (HIDStr);
     727    Acpi->UID = (UINT32)Strtoi (UIDStr);
     728  }
    711729
    712730  return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
     
    738756                                     );
    739757
    740   Acpi->HID = EFI_PNP_ID (PnPId);
    741   Acpi->UID = (UINT32)Strtoi (UIDStr);
     758  if (Acpi != NULL) {
     759    Acpi->HID = EFI_PNP_ID (PnPId);
     760    Acpi->UID = (UINT32)Strtoi (UIDStr);
     761  }
    742762
    743763  return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
     
    879899                                              );
    880900
    881   AcpiEx->HID = EisaIdFromText (HIDStr);
    882   AcpiEx->CID = EisaIdFromText (CIDStr);
    883   AcpiEx->UID = (UINT32)Strtoi (UIDStr);
    884 
    885   AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
    886   StrToAscii (HIDSTRStr, &AsciiStr);
    887   StrToAscii (UIDSTRStr, &AsciiStr);
    888   StrToAscii (CIDSTRStr, &AsciiStr);
     901  if (AcpiEx != NULL) {
     902    AcpiEx->HID = EisaIdFromText (HIDStr);
     903    AcpiEx->CID = EisaIdFromText (CIDStr);
     904    AcpiEx->UID = (UINT32)Strtoi (UIDStr);
     905
     906    AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
     907    StrToAscii (HIDSTRStr, &AsciiStr);
     908    StrToAscii (UIDSTRStr, &AsciiStr);
     909    StrToAscii (CIDSTRStr, &AsciiStr);
     910  }
    889911
    890912  return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
     
    921943                                                 );
    922944
     945  if (AcpiEx == NULL) {
     946    return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
     947  }
     948
    923949  AcpiEx->HID = EisaIdFromText (HIDStr);
    924950  //
    925   // According to UEFI spec, the CID parametr is optional and has a default value of 0.
    926   // So when the CID parametr is not specified or specified as 0 in the text device node.
     951  // According to UEFI spec, the CID parameter is optional and has a default value of 0.
     952  // So when the CID parameter is not specified or specified as 0 in the text device node.
    927953  // Set the CID to 0 in the ACPI extension device path structure.
    928954  //
     
    9761002                                      (UINT16)sizeof (ACPI_ADR_DEVICE_PATH)
    9771003                                      );
    978   ASSERT (AcpiAdr != NULL);
     1004  if (AcpiAdr == NULL) {
     1005    ASSERT (AcpiAdr != NULL);
     1006    return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
     1007  }
    9791008
    9801009  for (Index = 0; ; Index++) {
     
    9911020                  AcpiAdr
    9921021                  );
    993       ASSERT (AcpiAdr != NULL);
     1022
     1023      if (AcpiAdr == NULL) {
     1024        ASSERT (AcpiAdr != NULL);
     1025        return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
     1026      }
     1027
    9941028      SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
    9951029    }
     
    10401074                                 (UINT16)sizeof (ATAPI_DEVICE_PATH)
    10411075                                 );
     1076
     1077  if (Atapi == NULL) {
     1078    return (EFI_DEVICE_PATH_PROTOCOL *)Atapi;
     1079  }
    10421080
    10431081  PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
     
    10911129                                 );
    10921130
    1093   Scsi->Pun = (UINT16)Strtoi (PunStr);
    1094   Scsi->Lun = (UINT16)Strtoi (LunStr);
     1131  if (Scsi != NULL) {
     1132    Scsi->Pun = (UINT16)Strtoi (PunStr);
     1133    Scsi->Lun = (UINT16)Strtoi (LunStr);
     1134  }
    10951135
    10961136  return (EFI_DEVICE_PATH_PROTOCOL *)Scsi;
     
    11221162                                         );
    11231163
    1124   Fibre->Reserved = 0;
    1125   Strtoi64 (WWNStr, &Fibre->WWN);
    1126   Strtoi64 (LunStr, &Fibre->Lun);
     1164  if (Fibre != NULL) {
     1165    Fibre->Reserved = 0;
     1166    Strtoi64 (WWNStr, &Fibre->WWN);
     1167    Strtoi64 (LunStr, &Fibre->Lun);
     1168  }
    11271169
    11281170  return (EFI_DEVICE_PATH_PROTOCOL *)Fibre;
     
    11541196                                            );
    11551197
    1156   FibreEx->Reserved = 0;
    1157   Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN));
    1158   Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun));
    1159 
    1160   *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN));
    1161   *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun));
     1198  if (FibreEx != NULL) {
     1199    FibreEx->Reserved = 0;
     1200    Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN));
     1201    Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun));
     1202
     1203    *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN));
     1204    *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun));
     1205  }
    11621206
    11631207  return (EFI_DEVICE_PATH_PROTOCOL *)FibreEx;
     
    11871231                                        );
    11881232
    1189   F1394DevPath->Reserved = 0;
    1190   F1394DevPath->Guid     = StrHexToUint64 (GuidStr);
     1233  if (F1394DevPath != NULL) {
     1234    F1394DevPath->Reserved = 0;
     1235    F1394DevPath->Guid     = StrHexToUint64 (GuidStr);
     1236  }
    11911237
    11921238  return (EFI_DEVICE_PATH_PROTOCOL *)F1394DevPath;
     
    12181264                                      );
    12191265
    1220   Usb->ParentPortNumber = (UINT8)Strtoi (PortStr);
    1221   Usb->InterfaceNumber  = (UINT8)Strtoi (InterfaceStr);
     1266  if (Usb != NULL) {
     1267    Usb->ParentPortNumber = (UINT8)Strtoi (PortStr);
     1268    Usb->InterfaceNumber  = (UINT8)Strtoi (InterfaceStr);
     1269  }
    12221270
    12231271  return (EFI_DEVICE_PATH_PROTOCOL *)Usb;
     
    12471295                                    );
    12481296
    1249   I2ODevPath->Tid = (UINT32)Strtoi (TIDStr);
     1297  if (I2ODevPath != NULL) {
     1298    I2ODevPath->Tid = (UINT32)Strtoi (TIDStr);
     1299  }
    12501300
    12511301  return (EFI_DEVICE_PATH_PROTOCOL *)I2ODevPath;
     
    12831333                                           );
    12841334
    1285   InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr);
    1286   StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid);
    1287   Strtoi64 (SidStr, &InfiniBand->ServiceId);
    1288   Strtoi64 (TidStr, &InfiniBand->TargetPortId);
    1289   Strtoi64 (DidStr, &InfiniBand->DeviceId);
     1335  if (InfiniBand != NULL) {
     1336    InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr);
     1337    StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid);
     1338    Strtoi64 (SidStr, &InfiniBand->ServiceId);
     1339    Strtoi64 (TidStr, &InfiniBand->TargetPortId);
     1340    Strtoi64 (DidStr, &InfiniBand->DeviceId);
     1341  }
    12901342
    12911343  return (EFI_DEVICE_PATH_PROTOCOL *)InfiniBand;
     
    13321384                                   (UINT16)sizeof (VENDOR_DEVICE_PATH)
    13331385                                   );
    1334   CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
     1386
     1387  if (Vendor != NULL) {
     1388    CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
     1389  }
    13351390
    13361391  return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
     
    13571412                                   (UINT16)sizeof (VENDOR_DEVICE_PATH)
    13581413                                   );
    1359   CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
     1414
     1415  if (Vendor != NULL) {
     1416    CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
     1417  }
    13601418
    13611419  return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
     
    13821440                                   (UINT16)sizeof (VENDOR_DEVICE_PATH)
    13831441                                   );
    1384   CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
     1442
     1443  if (Vendor != NULL) {
     1444    CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
     1445  }
    13851446
    13861447  return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
     
    14071468                                   (UINT16)sizeof (VENDOR_DEVICE_PATH)
    14081469                                   );
    1409   CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
     1470
     1471  if (Vendor != NULL) {
     1472    CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
     1473  }
    14101474
    14111475  return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
     
    14351499                                                       );
    14361500
    1437   CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
    1438   if (StrCmp (ValueStr, L"XonXoff") == 0) {
    1439     UartFlowControl->FlowControlMap = 2;
    1440   } else if (StrCmp (ValueStr, L"Hardware") == 0) {
    1441     UartFlowControl->FlowControlMap = 1;
    1442   } else {
    1443     UartFlowControl->FlowControlMap = 0;
     1501  if (UartFlowControl != NULL) {
     1502    CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
     1503    if (StrCmp (ValueStr, L"XonXoff") == 0) {
     1504      UartFlowControl->FlowControlMap = 2;
     1505    } else if (StrCmp (ValueStr, L"Hardware") == 0) {
     1506      UartFlowControl->FlowControlMap = 1;
     1507    } else {
     1508      UartFlowControl->FlowControlMap = 0;
     1509    }
    14441510  }
    14451511
     
    14861552                                     );
    14871553
     1554  if (Sas == NULL) {
     1555    return (EFI_DEVICE_PATH_PROTOCOL *)Sas;
     1556  }
     1557
    14881558  CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
    14891559  Strtoi64 (AddressStr, &Sas->SasAddress);
     
    15811651                                       );
    15821652
     1653  if (SasEx == NULL) {
     1654    return (EFI_DEVICE_PATH_PROTOCOL *)SasEx;
     1655  }
     1656
    15831657  Strtoi64 (AddressStr, &SasAddress);
    15841658  Strtoi64 (LunStr, &Lun);
     
    16641738                                                     );
    16651739
    1666   Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr);
    1667   Uuid              = (UINT8 *)&Nvme->NamespaceUuid;
    1668 
    1669   Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
    1670   while (Index-- != 0) {
    1671     Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));
     1740  if (Nvme != NULL) {
     1741    Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr);
     1742    Uuid              = (UINT8 *)&Nvme->NamespaceUuid;
     1743
     1744    Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
     1745    while (Index-- != 0) {
     1746      Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));
     1747    }
    16721748  }
    16731749
     
    17001776                                );
    17011777
    1702   Ufs->Pun = (UINT8)Strtoi (PunStr);
    1703   Ufs->Lun = (UINT8)Strtoi (LunStr);
     1778  if (Ufs != NULL) {
     1779    Ufs->Pun = (UINT8)Strtoi (PunStr);
     1780    Ufs->Lun = (UINT8)Strtoi (LunStr);
     1781  }
    17041782
    17051783  return (EFI_DEVICE_PATH_PROTOCOL *)Ufs;
     
    17291807                                      );
    17301808
    1731   Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
     1809  if (Sd != NULL) {
     1810    Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
     1811  }
    17321812
    17331813  return (EFI_DEVICE_PATH_PROTOCOL *)Sd;
     
    17571837                                        );
    17581838
    1759   Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
     1839  if (Emmc != NULL) {
     1840    Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
     1841  }
    17601842
    17611843  return (EFI_DEVICE_PATH_PROTOCOL *)Emmc;
     
    17831865                                 );
    17841866
    1785   CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
     1867  if (Vend != NULL) {
     1868    CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
     1869  }
    17861870
    17871871  return (EFI_DEVICE_PATH_PROTOCOL *)Vend;
     
    18141898                                         );
    18151899
    1816   MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr);
    1817 
    1818   Length = sizeof (EFI_MAC_ADDRESS);
    1819   if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) {
    1820     Length = 6;
    1821   }
    1822 
    1823   StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
     1900  if (MACDevPath != NULL) {
     1901    MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr);
     1902
     1903    Length = sizeof (EFI_MAC_ADDRESS);
     1904    if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) {
     1905      Length = 6;
     1906    }
     1907
     1908    StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
     1909  }
    18241910
    18251911  return (EFI_DEVICE_PATH_PROTOCOL *)MACDevPath;
     
    18831969                                        );
    18841970
     1971  if (IPv4 == NULL) {
     1972    return (EFI_DEVICE_PATH_PROTOCOL *)IPv4;
     1973  }
     1974
    18851975  StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
    18861976  IPv4->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
     
    19392029                                          );
    19402030
     2031  if (IPv6 == NULL) {
     2032    return (EFI_DEVICE_PATH_PROTOCOL *)IPv6;
     2033  }
     2034
    19412035  StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
    19422036  IPv6->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
     
    19922086                                      (UINT16)sizeof (UART_DEVICE_PATH)
    19932087                                      );
     2088
     2089  if (Uart == NULL) {
     2090    return (EFI_DEVICE_PATH_PROTOCOL *)Uart;
     2091  }
    19942092
    19952093  if (StrCmp (BaudStr, L"DEFAULT") == 0) {
     
    20722170                                        (UINT16)sizeof (USB_CLASS_DEVICE_PATH)
    20732171                                        );
     2172
     2173  if (UsbClass == NULL) {
     2174    return (EFI_DEVICE_PATH_PROTOCOL *)UsbClass;
     2175  }
    20742176
    20752177  VIDStr = GetNextParamStr (&TextDeviceNode);
     
    25142616                                      (UINT16)(sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
    25152617                                      );
    2516   UsbWwid->VendorId        = (UINT16)Strtoi (VIDStr);
    2517   UsbWwid->ProductId       = (UINT16)Strtoi (PIDStr);
    2518   UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr);
    2519 
    2520   //
    2521   // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
    2522   // Therefore, the '\0' will not be copied.
    2523   //
    2524   CopyMem (
    2525     (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
    2526     SerialNumberStr,
    2527     SerialNumberStrLen * sizeof (CHAR16)
    2528     );
     2618
     2619  if (UsbWwid != NULL) {
     2620    UsbWwid->VendorId        = (UINT16)Strtoi (VIDStr);
     2621    UsbWwid->ProductId       = (UINT16)Strtoi (PIDStr);
     2622    UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr);
     2623
     2624    //
     2625    // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
     2626    // Therefore, the '\0' will not be copied.
     2627    //
     2628    CopyMem (
     2629      (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
     2630      SerialNumberStr,
     2631      SerialNumberStrLen * sizeof (CHAR16)
     2632      );
     2633  }
    25292634
    25302635  return (EFI_DEVICE_PATH_PROTOCOL *)UsbWwid;
     
    25542659                                                     );
    25552660
    2556   LogicalUnit->Lun = (UINT8)Strtoi (LunStr);
     2661  if (LogicalUnit != NULL) {
     2662    LogicalUnit->Lun = (UINT8)Strtoi (LunStr);
     2663  }
    25572664
    25582665  return (EFI_DEVICE_PATH_PROTOCOL *)LogicalUnit;
     
    25972704                                                       );
    25982705
     2706  if (ISCSIDevPath == NULL) {
     2707    return (EFI_DEVICE_PATH_PROTOCOL *)ISCSIDevPath;
     2708  }
     2709
    25992710  AsciiStr = ISCSIDevPath->TargetName;
    26002711  StrToAscii (NameStr, &AsciiStr);
     
    26582769                                  );
    26592770
    2660   Vlan->VlanId = (UINT16)Strtoi (VlanStr);
     2771  if (Vlan != NULL) {
     2772    Vlan->VlanId = (UINT16)Strtoi (VlanStr);
     2773  }
    26612774
    26622775  return (EFI_DEVICE_PATH_PROTOCOL *)Vlan;
     
    26852798                                            (UINT16)sizeof (BLUETOOTH_DEVICE_PATH)
    26862799                                            );
    2687   StrHexToBytes (
    2688     BluetoothStr,
    2689     sizeof (BLUETOOTH_ADDRESS) * 2,
    2690     BluetoothDp->BD_ADDR.Address,
    2691     sizeof (BLUETOOTH_ADDRESS)
    2692     );
     2800
     2801  if (BluetoothDp != NULL) {
     2802    StrHexToBytes (
     2803      BluetoothStr,
     2804      sizeof (BLUETOOTH_ADDRESS) * 2,
     2805      BluetoothDp->BD_ADDR.Address,
     2806      sizeof (BLUETOOTH_ADDRESS)
     2807      );
     2808  }
     2809
    26932810  return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothDp;
    26942811}
     
    27192836                                  );
    27202837
    2721   if (NULL != SSIdStr) {
     2838  if ((NULL != SSIdStr) && (NULL != WiFiDp)) {
    27222839    DataLen = StrLen (SSIdStr);
    27232840    if (StrLen (SSIdStr) > 32) {
     
    27582875                                                         );
    27592876
    2760   BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr);
    2761   StrHexToBytes (
    2762     BluetoothLeAddrStr,
    2763     sizeof (BluetoothLeDp->Address.Address) * 2,
    2764     BluetoothLeDp->Address.Address,
    2765     sizeof (BluetoothLeDp->Address.Address)
    2766     );
     2877  if (BluetoothLeDp != NULL) {
     2878    BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr);
     2879    StrHexToBytes (
     2880      BluetoothLeAddrStr,
     2881      sizeof (BluetoothLeDp->Address.Address) * 2,
     2882      BluetoothLeDp->Address.Address,
     2883      sizeof (BluetoothLeDp->Address.Address)
     2884      );
     2885  }
     2886
    27672887  return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothLeDp;
    27682888}
     
    28843004                                   );
    28853005
    2886   while (UriLength-- != 0) {
     3006  while (Uri != NULL && UriLength-- != 0) {
    28873007    Uri->Uri[UriLength] = (CHAR8)UriStr[UriLength];
    28883008  }
     
    29393059                                            );
    29403060
     3061  if (Hd == NULL) {
     3062    return (EFI_DEVICE_PATH_PROTOCOL *)Hd;
     3063  }
     3064
    29413065  Hd->PartitionNumber = (UINT32)Strtoi (PartitionStr);
    29423066
     
    29923116                                        );
    29933117
    2994   CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr);
    2995   Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
    2996   Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
     3118  if (CDROMDevPath != NULL) {
     3119    CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr);
     3120    Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
     3121    Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
     3122  }
    29973123
    29983124  return (EFI_DEVICE_PATH_PROTOCOL *)CDROMDevPath;
     
    30403166                                   );
    30413167
    3042   StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
     3168  if (File != NULL) {
     3169    StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
     3170  }
    30433171
    30443172  return (EFI_DEVICE_PATH_PROTOCOL *)File;
     
    30683196                                            );
    30693197
    3070   StrToGuid (GuidStr, &Media->Protocol);
     3198  if (Media != NULL) {
     3199    StrToGuid (GuidStr, &Media->Protocol);
     3200  }
    30713201
    30723202  return (EFI_DEVICE_PATH_PROTOCOL *)Media;
     
    30963226                                          );
    30973227
    3098   StrToGuid (GuidStr, &Fv->FvName);
     3228  if (Fv != NULL) {
     3229    StrToGuid (GuidStr, &Fv->FvName);
     3230  }
    30993231
    31003232  return (EFI_DEVICE_PATH_PROTOCOL *)Fv;
     
    31243256                                                   );
    31253257
    3126   StrToGuid (GuidStr, &FvFile->FvFileName);
     3258  if (FvFile != NULL) {
     3259    StrToGuid (GuidStr, &FvFile->FvFileName);
     3260  }
    31273261
    31283262  return (EFI_DEVICE_PATH_PROTOCOL *)FvFile;
     
    31543288                                                                   );
    31553289
    3156   Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
    3157   Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
     3290  if (Offset != NULL) {
     3291    Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
     3292    Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
     3293  }
    31583294
    31593295  return (EFI_DEVICE_PATH_PROTOCOL *)Offset;
     
    31913327                                                    );
    31923328
    3193   Strtoi64 (StartingAddrStr, &StartingAddr);
    3194   WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
    3195   Strtoi64 (EndingAddrStr, &EndingAddr);
    3196   WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
    3197   RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
    3198   StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
     3329  if (RamDisk != NULL) {
     3330    Strtoi64 (StartingAddrStr, &StartingAddr);
     3331    WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
     3332    Strtoi64 (EndingAddrStr, &EndingAddr);
     3333    WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
     3334    RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
     3335    StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
     3336  }
    31993337
    32003338  return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
     
    32313369                                            );
    32323370
    3233   Strtoi64 (StartingAddrStr, &StartingAddr);
    3234   WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
    3235   Strtoi64 (EndingAddrStr, &EndingAddr);
    3236   WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
    3237   RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
    3238   CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
     3371  if (RamDisk != NULL) {
     3372    Strtoi64 (StartingAddrStr, &StartingAddr);
     3373    WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
     3374    Strtoi64 (EndingAddrStr, &EndingAddr);
     3375    WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
     3376    RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
     3377    CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
     3378  }
    32393379
    32403380  return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
     
    32713411                                            );
    32723412
    3273   Strtoi64 (StartingAddrStr, &StartingAddr);
    3274   WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
    3275   Strtoi64 (EndingAddrStr, &EndingAddr);
    3276   WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
    3277   RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
    3278   CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
     3413  if (RamDisk != NULL) {
     3414    Strtoi64 (StartingAddrStr, &StartingAddr);
     3415    WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
     3416    Strtoi64 (EndingAddrStr, &EndingAddr);
     3417    WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
     3418    RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
     3419    CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
     3420  }
    32793421
    32803422  return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
     
    33113453                                            );
    33123454
    3313   Strtoi64 (StartingAddrStr, &StartingAddr);
    3314   WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
    3315   Strtoi64 (EndingAddrStr, &EndingAddr);
    3316   WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
    3317   RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
    3318   CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
     3455  if (RamDisk != NULL) {
     3456    Strtoi64 (StartingAddrStr, &StartingAddr);
     3457    WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
     3458    Strtoi64 (EndingAddrStr, &EndingAddr);
     3459    WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
     3460    RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
     3461    CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
     3462  }
    33193463
    33203464  return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
     
    33513495                                            );
    33523496
    3353   Strtoi64 (StartingAddrStr, &StartingAddr);
    3354   WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
    3355   Strtoi64 (EndingAddrStr, &EndingAddr);
    3356   WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
    3357   RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
    3358   CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
     3497  if (RamDisk != NULL) {
     3498    Strtoi64 (StartingAddrStr, &StartingAddr);
     3499    WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
     3500    Strtoi64 (EndingAddrStr, &EndingAddr);
     3501    WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
     3502    RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
     3503    CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
     3504  }
    33593505
    33603506  return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
     
    34043550                                      (UINT16)(sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
    34053551                                      );
     3552
     3553  if (Bbs == NULL) {
     3554    return (EFI_DEVICE_PATH_PROTOCOL *)Bbs;
     3555  }
    34063556
    34073557  if (StrCmp (TypeStr, L"Floppy") == 0) {
     
    34563606                               (UINT16)sizeof (SATA_DEVICE_PATH)
    34573607                               );
     3608
     3609  if (Sata == NULL) {
     3610    return (EFI_DEVICE_PATH_PROTOCOL *)Sata;
     3611  }
     3612
    34583613  Sata->HBAPortNumber = (UINT16)Strtoi (Param1);
    34593614
     
    36573812
    36583813  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
    3659   ASSERT (DevicePath != NULL);
     3814
     3815  if (DevicePath == NULL) {
     3816    ASSERT (DevicePath != NULL);
     3817    return NULL;
     3818  }
     3819
    36603820  SetDevicePathEndNode (DevicePath);
    36613821
    36623822  DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
     3823
     3824  if (DevicePathStr == NULL) {
     3825    return NULL;
     3826  }
    36633827
    36643828  Str = DevicePathStr;
     
    36673831
    36683832    NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
    3669     FreePool (DevicePath);
    3670     FreePool (DeviceNode);
     3833    if (DevicePath != NULL) {
     3834      FreePool (DevicePath);
     3835    }
     3836
     3837    if (DeviceNode != NULL) {
     3838      FreePool (DeviceNode);
     3839    }
     3840
    36713841    DevicePath = NewDevicePath;
    36723842
    36733843    if (IsInstanceEnd) {
    36743844      DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
    3675       ASSERT (DeviceNode != NULL);
     3845      if (DeviceNode == NULL) {
     3846        ASSERT (DeviceNode != NULL);
     3847        return NULL;
     3848      }
     3849
    36763850      SetDevicePathEndNode (DeviceNode);
    36773851      DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
    36783852
    36793853      NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
    3680       FreePool (DevicePath);
    3681       FreePool (DeviceNode);
     3854      if (DevicePath != NULL) {
     3855        FreePool (DevicePath);
     3856      }
     3857
     3858      if (DeviceNode != NULL) {
     3859        FreePool (DeviceNode);
     3860      }
     3861
    36823862      DevicePath = NewDevicePath;
    36833863    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette