From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mx.groups.io with SMTP id smtpd.web12.834.1665305748293072304 for ; Sun, 09 Oct 2022 01:55:49 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.189, mailfrom: xiewenyi2@huawei.com) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MlbRc4T57zrS7l; Sun, 9 Oct 2022 16:53:16 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 9 Oct 2022 16:55:45 +0800 Received: from kwephisprg16640.huawei.com (10.247.83.252) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 9 Oct 2022 16:55:44 +0800 From: "wenyi,xie" To: , , , CC: , Subject: [PATCH EDK2 v1 1/1] MdePkg/UefiDevicePathLib:Add NULL point check Date: Sun, 9 Oct 2022 16:55:30 +0800 Message-ID: <20221009085530.2443273-2-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20221009085530.2443273-1-xiewenyi2@huawei.com> References: <20221009085530.2443273-1-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.247.83.252] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected Content-Type: text/plain REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4060 Function CreateDeviceNode may return NULL point when NodeLength is smaller than a device path header or there is not enough memory to allocate. But after calling CreateDeviceNode, the pointer is dereferenced without checking its value. So is it nessary to check the value of point before using. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Wenyi Xie --- MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 240 ++++++++++++++++++++ 1 file changed, 240 insertions(+) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c index 1aaa968d6fb5..702b4ad74b30 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c @@ -388,6 +388,10 @@ DevPathFromTextGenericPath ( (UINT16)(sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength) ); + if (Node == NULL) { + return NULL; + } + StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength); return Node; } @@ -453,6 +457,10 @@ DevPathFromTextPci ( (UINT16)sizeof (PCI_DEVICE_PATH) ); + if (Pci == NULL) { + return NULL; + } + Pci->Function = (UINT8)Strtoi (FunctionStr); Pci->Device = (UINT8)Strtoi (DeviceStr); @@ -482,6 +490,10 @@ DevPathFromTextPcCard ( (UINT16)sizeof (PCCARD_DEVICE_PATH) ); + if (Pccard == NULL) { + return NULL; + } + Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr); return (EFI_DEVICE_PATH_PROTOCOL *)Pccard; @@ -514,6 +526,10 @@ DevPathFromTextMemoryMapped ( (UINT16)sizeof (MEMMAP_DEVICE_PATH) ); + if (MemMap == NULL) { + return NULL; + } + MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr); Strtoi64 (StartingAddressStr, &MemMap->StartingAddress); Strtoi64 (EndingAddressStr, &MemMap->EndingAddress); @@ -559,6 +575,10 @@ ConvertFromTextVendor ( (UINT16)(sizeof (VENDOR_DEVICE_PATH) + Length) ); + if (Vendor == NULL) { + return NULL; + } + StrToGuid (GuidStr, &Vendor->Guid); StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length); @@ -607,6 +627,11 @@ DevPathFromTextCtrl ( HW_CONTROLLER_DP, (UINT16)sizeof (CONTROLLER_DEVICE_PATH) ); + + if (Controller == NULL) { + return NULL; + } + Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr); return (EFI_DEVICE_PATH_PROTOCOL *)Controller; @@ -637,6 +662,10 @@ DevPathFromTextBmc ( (UINT16)sizeof (BMC_DEVICE_PATH) ); + if (BmcDp == NULL) { + return NULL; + } + BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr); WriteUnaligned64 ( (UINT64 *)(&BmcDp->BaseAddress), @@ -706,6 +735,10 @@ DevPathFromTextAcpi ( (UINT16)sizeof (ACPI_HID_DEVICE_PATH) ); + if (Acpi == NULL) { + return NULL; + } + Acpi->HID = EisaIdFromText (HIDStr); Acpi->UID = (UINT32)Strtoi (UIDStr); @@ -737,6 +770,10 @@ ConvertFromTextAcpi ( (UINT16)sizeof (ACPI_HID_DEVICE_PATH) ); + if (Acpi == NULL) { + return NULL; + } + Acpi->HID = EFI_PNP_ID (PnPId); Acpi->UID = (UINT32)Strtoi (UIDStr); @@ -878,6 +915,10 @@ DevPathFromTextAcpiEx ( Length ); + if (AcpiEx == NULL) { + return NULL; + } + AcpiEx->HID = EisaIdFromText (HIDStr); AcpiEx->CID = EisaIdFromText (CIDStr); AcpiEx->UID = (UINT32)Strtoi (UIDStr); @@ -920,6 +961,10 @@ DevPathFromTextAcpiExp ( Length ); + if (AcpiEx == NULL) { + return NULL; + } + AcpiEx->HID = EisaIdFromText (HIDStr); // // According to UEFI spec, the CID parametr is optional and has a default value of 0. @@ -1040,6 +1085,10 @@ DevPathFromTextAta ( (UINT16)sizeof (ATAPI_DEVICE_PATH) ); + if (Atapi == NULL) { + return NULL; + } + PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode); SlaveMasterStr = GetNextParamStr (&TextDeviceNode); LunStr = GetNextParamStr (&TextDeviceNode); @@ -1090,6 +1139,10 @@ DevPathFromTextScsi ( (UINT16)sizeof (SCSI_DEVICE_PATH) ); + if (Scsi == NULL) { + return NULL; + } + Scsi->Pun = (UINT16)Strtoi (PunStr); Scsi->Lun = (UINT16)Strtoi (LunStr); @@ -1121,6 +1174,10 @@ DevPathFromTextFibre ( (UINT16)sizeof (FIBRECHANNEL_DEVICE_PATH) ); + if (Fibre == NULL) { + return NULL; + } + Fibre->Reserved = 0; Strtoi64 (WWNStr, &Fibre->WWN); Strtoi64 (LunStr, &Fibre->Lun); @@ -1153,6 +1210,10 @@ DevPathFromTextFibreEx ( (UINT16)sizeof (FIBRECHANNELEX_DEVICE_PATH) ); + if (FibreEx == NULL) { + return NULL; + } + FibreEx->Reserved = 0; Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN)); Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun)); @@ -1186,6 +1247,10 @@ DevPathFromText1394 ( (UINT16)sizeof (F1394_DEVICE_PATH) ); + if (F1394DevPath == NULL) { + return NULL; + } + F1394DevPath->Reserved = 0; F1394DevPath->Guid = StrHexToUint64 (GuidStr); @@ -1217,6 +1282,10 @@ DevPathFromTextUsb ( (UINT16)sizeof (USB_DEVICE_PATH) ); + if (Usb == NULL) { + return NULL; + } + Usb->ParentPortNumber = (UINT8)Strtoi (PortStr); Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr); @@ -1246,6 +1315,10 @@ DevPathFromTextI2O ( (UINT16)sizeof (I2O_DEVICE_PATH) ); + if (I2ODevPath == NULL) { + return NULL; + } + I2ODevPath->Tid = (UINT32)Strtoi (TIDStr); return (EFI_DEVICE_PATH_PROTOCOL *)I2ODevPath; @@ -1282,6 +1355,10 @@ DevPathFromTextInfiniband ( (UINT16)sizeof (INFINIBAND_DEVICE_PATH) ); + if (InfiniBand == NULL) { + return NULL; + } + InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr); StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid); Strtoi64 (SidStr, &InfiniBand->ServiceId); @@ -1331,6 +1408,11 @@ DevPathFromTextVenPcAnsi ( MSG_VENDOR_DP, (UINT16)sizeof (VENDOR_DEVICE_PATH) ); + + if (Vendor == NULL) { + return NULL; + } + CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid); return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; @@ -1356,6 +1438,11 @@ DevPathFromTextVenVt100 ( MSG_VENDOR_DP, (UINT16)sizeof (VENDOR_DEVICE_PATH) ); + + if (Vendor == NULL) { + return NULL; + } + CopyGuid (&Vendor->Guid, &gEfiVT100Guid); return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; @@ -1381,6 +1468,11 @@ DevPathFromTextVenVt100Plus ( MSG_VENDOR_DP, (UINT16)sizeof (VENDOR_DEVICE_PATH) ); + + if (Vendor == NULL) { + return NULL; + } + CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid); return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; @@ -1406,6 +1498,11 @@ DevPathFromTextVenUtf8 ( MSG_VENDOR_DP, (UINT16)sizeof (VENDOR_DEVICE_PATH) ); + + if (Vendor == NULL) { + return NULL; + } + CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid); return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; @@ -1434,6 +1531,10 @@ DevPathFromTextUartFlowCtrl ( (UINT16)sizeof (UART_FLOW_CONTROL_DEVICE_PATH) ); + if (UartFlowControl == NULL) { + return NULL; + } + CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid); if (StrCmp (ValueStr, L"XonXoff") == 0) { UartFlowControl->FlowControlMap = 2; @@ -1485,6 +1586,10 @@ DevPathFromTextSAS ( (UINT16)sizeof (SAS_DEVICE_PATH) ); + if (Sas == NULL) { + return NULL; + } + CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid); Strtoi64 (AddressStr, &Sas->SasAddress); Strtoi64 (LunStr, &Sas->Lun); @@ -1580,6 +1685,10 @@ DevPathFromTextSasEx ( (UINT16)sizeof (SASEX_DEVICE_PATH) ); + if (SasEx == NULL) { + return NULL; + } + Strtoi64 (AddressStr, &SasAddress); Strtoi64 (LunStr, &Lun); WriteUnaligned64 ((UINT64 *)&SasEx->SasAddress, SwapBytes64 (SasAddress)); @@ -1663,6 +1772,10 @@ DevPathFromTextNVMe ( (UINT16)sizeof (NVME_NAMESPACE_DEVICE_PATH) ); + if (Nvme == NULL) { + return NULL; + } + Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr); Uuid = (UINT8 *)&Nvme->NamespaceUuid; @@ -1699,6 +1812,10 @@ DevPathFromTextUfs ( (UINT16)sizeof (UFS_DEVICE_PATH) ); + if (Ufs == NULL) { + return NULL; + } + Ufs->Pun = (UINT8)Strtoi (PunStr); Ufs->Lun = (UINT8)Strtoi (LunStr); @@ -1728,6 +1845,10 @@ DevPathFromTextSd ( (UINT16)sizeof (SD_DEVICE_PATH) ); + if (Sd == NULL) { + return NULL; + } + Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr); return (EFI_DEVICE_PATH_PROTOCOL *)Sd; @@ -1756,6 +1877,10 @@ DevPathFromTextEmmc ( (UINT16)sizeof (EMMC_DEVICE_PATH) ); + if (Emmc == NULL) { + return NULL; + } + Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr); return (EFI_DEVICE_PATH_PROTOCOL *)Emmc; @@ -1782,6 +1907,10 @@ DevPathFromTextDebugPort ( (UINT16)sizeof (VENDOR_DEVICE_PATH) ); + if (Vend == NULL) { + return NULL; + } + CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid); return (EFI_DEVICE_PATH_PROTOCOL *)Vend; @@ -1813,6 +1942,10 @@ DevPathFromTextMAC ( (UINT16)sizeof (MAC_ADDR_DEVICE_PATH) ); + if (MACDevPath == NULL) { + return NULL; + } + MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr); Length = sizeof (EFI_MAC_ADDRESS); @@ -1882,6 +2015,10 @@ DevPathFromTextIPv4 ( (UINT16)sizeof (IPv4_DEVICE_PATH) ); + if (IPv4 == NULL) { + return NULL; + } + StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL); IPv4->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr); if (StrCmp (TypeStr, L"Static") == 0) { @@ -1938,6 +2075,10 @@ DevPathFromTextIPv6 ( (UINT16)sizeof (IPv6_DEVICE_PATH) ); + if (IPv6 == NULL) { + return NULL; + } + StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL); IPv6->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr); if (StrCmp (TypeStr, L"Static") == 0) { @@ -1992,6 +2133,10 @@ DevPathFromTextUart ( (UINT16)sizeof (UART_DEVICE_PATH) ); + if (Uart == NULL) { + return NULL; + } + if (StrCmp (BaudStr, L"DEFAULT") == 0) { Uart->BaudRate = 115200; } else { @@ -2072,6 +2217,10 @@ ConvertFromTextUsbClass ( (UINT16)sizeof (USB_CLASS_DEVICE_PATH) ); + if (UsbClass == NULL) { + return NULL; + } + VIDStr = GetNextParamStr (&TextDeviceNode); PIDStr = GetNextParamStr (&TextDeviceNode); if (UsbClassText->ClassExist) { @@ -2513,6 +2662,11 @@ DevPathFromTextUsbWwid ( MSG_USB_WWID_DP, (UINT16)(sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16)) ); + + if (UsbWwid == NULL) { + return NULL; + } + UsbWwid->VendorId = (UINT16)Strtoi (VIDStr); UsbWwid->ProductId = (UINT16)Strtoi (PIDStr); UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr); @@ -2553,6 +2707,10 @@ DevPathFromTextUnit ( (UINT16)sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH) ); + if (LogicalUnit == NULL) { + return NULL; + } + LogicalUnit->Lun = (UINT8)Strtoi (LunStr); return (EFI_DEVICE_PATH_PROTOCOL *)LogicalUnit; @@ -2596,6 +2754,10 @@ DevPathFromTextiSCSI ( (UINT16)(sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr)) ); + if (ISCSIDevPath == NULL) { + return NULL; + } + AsciiStr = ISCSIDevPath->TargetName; StrToAscii (NameStr, &AsciiStr); @@ -2657,6 +2819,10 @@ DevPathFromTextVlan ( (UINT16)sizeof (VLAN_DEVICE_PATH) ); + if (Vlan == NULL) { + return NULL; + } + Vlan->VlanId = (UINT16)Strtoi (VlanStr); return (EFI_DEVICE_PATH_PROTOCOL *)Vlan; @@ -2684,6 +2850,11 @@ DevPathFromTextBluetooth ( MSG_BLUETOOTH_DP, (UINT16)sizeof (BLUETOOTH_DEVICE_PATH) ); + + if (BluetoothDp == NULL) { + return NULL; + } + StrHexToBytes ( BluetoothStr, sizeof (BLUETOOTH_ADDRESS) * 2, @@ -2718,6 +2889,10 @@ DevPathFromTextWiFi ( (UINT16)sizeof (WIFI_DEVICE_PATH) ); + if (WiFiDp == NULL) { + return NULL; + } + if (NULL != SSIdStr) { DataLen = StrLen (SSIdStr); if (StrLen (SSIdStr) > 32) { @@ -2757,6 +2932,10 @@ DevPathFromTextBluetoothLE ( (UINT16)sizeof (BLUETOOTH_LE_DEVICE_PATH) ); + if (BluetoothLeDp == NULL) { + return NULL; + } + BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr); StrHexToBytes ( BluetoothLeAddrStr, @@ -2883,6 +3062,10 @@ DevPathFromTextUri ( (UINT16)(sizeof (URI_DEVICE_PATH) + UriLength) ); + if (Uri == NULL) { + return NULL; + } + while (UriLength-- != 0) { Uri->Uri[UriLength] = (CHAR8)UriStr[UriLength]; } @@ -2938,6 +3121,10 @@ DevPathFromTextHD ( (UINT16)sizeof (HARDDRIVE_DEVICE_PATH) ); + if (Hd == NULL) { + return NULL; + } + Hd->PartitionNumber = (UINT32)Strtoi (PartitionStr); ZeroMem (Hd->Signature, 16); @@ -2991,6 +3178,10 @@ DevPathFromTextCDROM ( (UINT16)sizeof (CDROM_DEVICE_PATH) ); + if (CDROMDevPath == NULL) { + return NULL; + } + CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr); Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); @@ -3039,6 +3230,10 @@ DevPathFromTextFilePath ( (UINT16)(sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2) ); + if (File == NULL) { + return NULL; + } + StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode); return (EFI_DEVICE_PATH_PROTOCOL *)File; @@ -3067,6 +3262,10 @@ DevPathFromTextMedia ( (UINT16)sizeof (MEDIA_PROTOCOL_DEVICE_PATH) ); + if (Media == NULL) { + return NULL; + } + StrToGuid (GuidStr, &Media->Protocol); return (EFI_DEVICE_PATH_PROTOCOL *)Media; @@ -3095,6 +3294,10 @@ DevPathFromTextFv ( (UINT16)sizeof (MEDIA_FW_VOL_DEVICE_PATH) ); + if (Fv == NULL) { + return NULL; + } + StrToGuid (GuidStr, &Fv->FvName); return (EFI_DEVICE_PATH_PROTOCOL *)Fv; @@ -3123,6 +3326,10 @@ DevPathFromTextFvFile ( (UINT16)sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH) ); + if (FvFile == NULL) { + return NULL; + } + StrToGuid (GuidStr, &FvFile->FvFileName); return (EFI_DEVICE_PATH_PROTOCOL *)FvFile; @@ -3153,6 +3360,10 @@ DevPathFromTextRelativeOffsetRange ( (UINT16)sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH) ); + if (Offset == NULL) { + return NULL; + } + Strtoi64 (StartingOffsetStr, &Offset->StartingOffset); Strtoi64 (EndingOffsetStr, &Offset->EndingOffset); @@ -3190,6 +3401,10 @@ DevPathFromTextRamDisk ( (UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH) ); + if (RamDisk == NULL) { + return NULL; + } + Strtoi64 (StartingAddrStr, &StartingAddr); WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); Strtoi64 (EndingAddrStr, &EndingAddr); @@ -3230,6 +3445,10 @@ DevPathFromTextVirtualDisk ( (UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH) ); + if (RamDisk == NULL) { + return NULL; + } + Strtoi64 (StartingAddrStr, &StartingAddr); WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); Strtoi64 (EndingAddrStr, &EndingAddr); @@ -3270,6 +3489,10 @@ DevPathFromTextVirtualCd ( (UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH) ); + if (RamDisk == NULL) { + return NULL; + } + Strtoi64 (StartingAddrStr, &StartingAddr); WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); Strtoi64 (EndingAddrStr, &EndingAddr); @@ -3310,6 +3533,10 @@ DevPathFromTextPersistentVirtualDisk ( (UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH) ); + if (RamDisk == NULL) { + return NULL; + } + Strtoi64 (StartingAddrStr, &StartingAddr); WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); Strtoi64 (EndingAddrStr, &EndingAddr); @@ -3350,6 +3577,10 @@ DevPathFromTextPersistentVirtualCd ( (UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH) ); + if (RamDisk == NULL) { + return NULL; + } + Strtoi64 (StartingAddrStr, &StartingAddr); WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); Strtoi64 (EndingAddrStr, &EndingAddr); @@ -3404,6 +3635,10 @@ DevPathFromTextBBS ( (UINT16)(sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr)) ); + if (Bbs == NULL) { + return NULL; + } + if (StrCmp (TypeStr, L"Floppy") == 0) { Bbs->DeviceType = BBS_TYPE_FLOPPY; } else if (StrCmp (TypeStr, L"HD") == 0) { @@ -3455,6 +3690,11 @@ DevPathFromTextSata ( MSG_SATA_DP, (UINT16)sizeof (SATA_DEVICE_PATH) ); + + if (Sata == NULL) { + return NULL; + } + Sata->HBAPortNumber = (UINT16)Strtoi (Param1); // -- 2.20.1.windows.1