summaryrefslogtreecommitdiffstats
path: root/drivers/efi
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2017-03-11 17:07:32 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-30 08:23:19 +0200
commit3e1af511f06021e138132f227a1746f44bbe8e31 (patch)
treec41147e0856a1a216a51809bb51543ac7bab7e57 /drivers/efi
parent441e9f5a72b245b671118f3e771eb129834a7a34 (diff)
downloadbarebox-3e1af511f06021e138132f227a1746f44bbe8e31.tar.gz
barebox-3e1af511f06021e138132f227a1746f44bbe8e31.tar.xz
efi: load the protocol expected by the driver
The drivers are loaded if any guid provided by the device matches. So load the protocol for the matched guid and not for the first guid. Otherwise the driver may cast the protocol to the wrong type and proably crash. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/efi')
-rw-r--r--drivers/efi/efi-device.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index 6ed7f12b37..7ab62a763a 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -183,8 +183,6 @@ static struct efi_device *efi_add_device(efi_handle_t *handle, efi_guid_t **guid
efidev->dev.info = efi_devinfo;
efidev->devpath = devpath;
- BS->handle_protocol(handle, &guidarr[0], &efidev->protocol);
-
sprintf(efidev->dev.name, "handle-%p", handle);
efidev->parent_handle = efi_find_parent(efidev->handle);
@@ -310,8 +308,11 @@ static int efi_bus_match(struct device_d *dev, struct driver_d *drv)
int i;
for (i = 0; i < efidev->num_guids; i++) {
- if (!memcmp(&efidrv->guid, &efidev->guids[i], sizeof(efi_guid_t)))
+ if (!memcmp(&efidrv->guid, &efidev->guids[i], sizeof(efi_guid_t))) {
+ BS->handle_protocol(efidev->handle, &efidev->guids[i],
+ &efidev->protocol);
return 0;
+ }
}
return 1;