summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/efi/nii.c
diff options
context:
space:
mode:
authorMichael Brown2014-10-17 17:50:45 +0200
committerMichael Brown2014-10-17 17:52:31 +0200
commitfeb3a0f7d56fd9fd342672069aa736660cea8089 (patch)
tree19be355847403f491ce51f1b96a5471c98e58b53 /src/drivers/net/efi/nii.c
parent[efi] Add NII / UNDI driver (diff)
downloadipxe-feb3a0f7d56fd9fd342672069aa736660cea8089.tar.gz
ipxe-feb3a0f7d56fd9fd342672069aa736660cea8089.tar.xz
ipxe-feb3a0f7d56fd9fd342672069aa736660cea8089.zip
[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>
Diffstat (limited to 'src/drivers/net/efi/nii.c')
-rw-r--r--src/drivers/net/efi/nii.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/drivers/net/efi/nii.c b/src/drivers/net/efi/nii.c
index 5b1872ca..56b6340b 100644
--- a/src/drivers/net/efi/nii.c
+++ b/src/drivers/net/efi/nii.c
@@ -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: