ソースを参照

[efi] Check for presence of UNDI in NII protocol

iPXE itself exposes a dummy NII protocol with no UNDI.  Avoid
potentially dereferencing a NULL pointer by checking for a non-zero
UNDI address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9年前
コミット
feb3a0f7d5
1個のファイルの変更6行の追加0行の削除
  1. 6
    0
      src/drivers/net/efi/nii.c

+ 6
- 0
src/drivers/net/efi/nii.c ファイルの表示

@@ -1037,6 +1037,11 @@ static int nii_start ( struct efi_device *efidev ) {
1037 1037
 
1038 1038
 	/* Locate UNDI and entry point */
1039 1039
 	nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id );
1040
+	if ( ! nii->undi ) {
1041
+		DBGC ( nii, "NII %s has no UNDI\n", nii->dev.name );
1042
+		rc = -ENODEV;
1043
+		goto err_no_undi;
1044
+	}
1040 1045
 	if ( nii->undi->Implementation & PXE_ROMID_IMP_HW_UNDI ) {
1041 1046
 		DBGC ( nii, "NII %s is a mythical hardware UNDI\n",
1042 1047
 		       nii->dev.name );
@@ -1085,6 +1090,7 @@ static int nii_start ( struct efi_device *efidev ) {
1085 1090
 	nii_pci_close ( nii );
1086 1091
  err_pci_open:
1087 1092
  err_hw_undi:
1093
+ err_no_undi:
1088 1094
 	bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
1089 1095
 			    efi_image_handle, device );
1090 1096
  err_open_protocol:

読み込み中…
キャンセル
保存