Browse Source

[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>
tags/v1.20.1
Michael Brown 4 years ago
parent
commit
a385e23768
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/interface/efi/efi_driver.c

+ 6
- 3
src/interface/efi/efi_driver.c View File

@@ -73,11 +73,14 @@ static struct efi_device * efidev_find ( EFI_HANDLE device ) {
73 73
  */
74 74
 struct efi_device * efidev_parent ( struct device *dev ) {
75 75
 	struct device *parent;
76
+	struct efi_device *efidev;
76 77
 
77
-	/* Walk upwards until we find an EFI device */
78
+	/* Walk upwards until we find a registered EFI device */
78 79
 	while ( ( parent = dev->parent ) ) {
79
-		if ( parent->desc.bus_type == BUS_TYPE_EFI )
80
-			return container_of ( parent, struct efi_device, dev );
80
+		list_for_each_entry ( efidev, &efi_devices, dev.siblings ) {
81
+			if ( parent == &efidev->dev )
82
+				return efidev;
83
+		}
81 84
 		dev = parent;
82 85
 	}
83 86
 

Loading…
Cancel
Save