Navigation Menu

Skip to content

Commit

Permalink
[efi] Return only registered EFI devices from efidev_parent()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mcb30 committed Jul 15, 2019
1 parent c2226b3 commit a385e23
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/interface/efi/efi_driver.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit a385e23

Please sign in to comment.