Browse Source

[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 10 years ago
parent
commit
feb3a0f7d5
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      src/drivers/net/efi/nii.c

+ 6
- 0
src/drivers/net/efi/nii.c View File

1037
 
1037
 
1038
 	/* Locate UNDI and entry point */
1038
 	/* Locate UNDI and entry point */
1039
 	nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id );
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
 	if ( nii->undi->Implementation & PXE_ROMID_IMP_HW_UNDI ) {
1045
 	if ( nii->undi->Implementation & PXE_ROMID_IMP_HW_UNDI ) {
1041
 		DBGC ( nii, "NII %s is a mythical hardware UNDI\n",
1046
 		DBGC ( nii, "NII %s is a mythical hardware UNDI\n",
1042
 		       nii->dev.name );
1047
 		       nii->dev.name );
1085
 	nii_pci_close ( nii );
1090
 	nii_pci_close ( nii );
1086
  err_pci_open:
1091
  err_pci_open:
1087
  err_hw_undi:
1092
  err_hw_undi:
1093
+ err_no_undi:
1088
 	bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
1094
 	bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
1089
 			    efi_image_handle, device );
1095
 			    efi_image_handle, device );
1090
  err_open_protocol:
1096
  err_open_protocol:

Loading…
Cancel
Save