diff options
author | Michael Brown <mcb30@ipxe.org> | 2019-07-15 12:49:47 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2019-07-15 12:49:47 +0100 |
commit | a385e2376859dc0195ec77aeab220876b201c16b (patch) | |
tree | 5c654730ac61146037965e752ef7092a0b76d89f | |
parent | c2226b3d1a4d9fc1daeb8dc6b9034d1fb46c1308 (diff) | |
download | ipxe-a385e2376859dc0195ec77aeab220876b201c16b.zip ipxe-a385e2376859dc0195ec77aeab220876b201c16b.tar.gz ipxe-a385e2376859dc0195ec77aeab220876b201c16b.tar.bz2 |
[efi] Return only registered EFI devices from efidev_parent()
efidev_parent() currently assumes that any device with BUS_TYPE_EFI is
part of a struct efi_device. This assumption is not valid, since the
code in efi_device_info() may also create a device with BUS_TYPE_EFI.
Fix by searching through the list of registered EFI devices when
looking for a match, instead of relying on the bus type value.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/interface/efi/efi_driver.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 0479641..7be2e58 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -73,11 +73,14 @@ static struct efi_device * efidev_find ( EFI_HANDLE device ) { */ struct efi_device * efidev_parent ( struct device *dev ) { struct device *parent; + struct efi_device *efidev; - /* Walk upwards until we find an EFI device */ + /* Walk upwards until we find a registered EFI device */ while ( ( parent = dev->parent ) ) { - if ( parent->desc.bus_type == BUS_TYPE_EFI ) - return container_of ( parent, struct efi_device, dev ); + list_for_each_entry ( efidev, &efi_devices, dev.siblings ) { + if ( parent == &efidev->dev ) + return efidev; + } dev = parent; } |