mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>
Subject: [PATCH 1/2] efi: load the protocol expected by the driver
Date: Sat, 11 Mar 2017 17:07:32 +0100	[thread overview]
Message-ID: <20170311160733.18473-1-m.olbrich@pengutronix.de> (raw)

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>
---
 drivers/efi/efi-device.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index 959878e7f5cf..c5fb404cd36b 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -184,8 +184,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);
@@ -311,8 +309,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;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2017-03-11 16:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 16:07 Michael Olbrich [this message]
2017-03-11 16:07 ` [PATCH 2/2] efi: only iterate over handles that provide the device path protocol Michael Olbrich
2017-03-14  7:13 ` [PATCH 1/2] efi: load the protocol expected by the driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170311160733.18473-1-m.olbrich@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox