]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Check for presence of UNDI in NII protocol
authorMichael Brown <mcb30@ipxe.org>
Fri, 17 Oct 2014 15:50:45 +0000 (16:50 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 17 Oct 2014 15:52:31 +0000 (16:52 +0100)
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>
src/drivers/net/efi/nii.c

index 5b1872caba0d1e312eb63f0d39c7ea02ed6bd62a..56b6340bf8ab89def647a84c4278df0aa6696478 100644 (file)
@@ -1037,6 +1037,11 @@ static int nii_start ( struct efi_device *efidev ) {
 
        /* Locate UNDI and entry point */
        nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id );
+       if ( ! nii->undi ) {
+               DBGC ( nii, "NII %s has no UNDI\n", nii->dev.name );
+               rc = -ENODEV;
+               goto err_no_undi;
+       }
        if ( nii->undi->Implementation & PXE_ROMID_IMP_HW_UNDI ) {
                DBGC ( nii, "NII %s is a mythical hardware UNDI\n",
                       nii->dev.name );
@@ -1085,6 +1090,7 @@ static int nii_start ( struct efi_device *efidev ) {
        nii_pci_close ( nii );
  err_pci_open:
  err_hw_undi:
+ err_no_undi:
        bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
                            efi_image_handle, device );
  err_open_protocol: