public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] efi_driver: fix a wrong cast
@ 2021-09-27  4:30 AKASHI Takahiro
  2021-09-27  7:48 ` Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: AKASHI Takahiro @ 2021-09-27  4:30 UTC (permalink / raw)
  To: xypron.glpk, agraf; +Cc: u-boot, AKASHI Takahiro

struct efi_driver_binding_protocol, i.e. bp, is not the first element
in struct efi_driver_binding_extended_protocol.
So the casting:
	struct efi_driver_binding_extended_protocol *bp =
		(struct efi_driver_binding_extended_protocol *)this;
is simply wrong.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 lib/efi_driver/efi_uclass.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index 382c2b477f4d..9e784f9c237f 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -65,8 +65,8 @@ static efi_status_t EFIAPI efi_uc_supported(
 {
 	efi_status_t r, ret;
 	void *interface;
-	struct efi_driver_binding_extended_protocol *bp =
-			(struct efi_driver_binding_extended_protocol *)this;
+	struct efi_driver_binding_extended_protocol *bp = container_of(this,
+			struct efi_driver_binding_extended_protocol, bp);
 
 	EFI_ENTRY("%p, %p, %ls", this, controller_handle,
 		  efi_dp_str(remaining_device_path));
@@ -113,8 +113,8 @@ static efi_status_t EFIAPI efi_uc_start(
 {
 	efi_status_t r, ret;
 	void *interface = NULL;
-	struct efi_driver_binding_extended_protocol *bp =
-			(struct efi_driver_binding_extended_protocol *)this;
+	struct efi_driver_binding_extended_protocol *bp = container_of(this,
+			struct efi_driver_binding_extended_protocol, bp);
 
 	EFI_ENTRY("%p, %p, %ls", this, controller_handle,
 		  efi_dp_str(remaining_device_path));
@@ -201,8 +201,8 @@ static efi_status_t EFIAPI efi_uc_stop(
 	efi_status_t ret;
 	efi_uintn_t count;
 	struct efi_open_protocol_info_entry *entry_buffer;
-	struct efi_driver_binding_extended_protocol *bp =
-			(struct efi_driver_binding_extended_protocol *)this;
+	struct efi_driver_binding_extended_protocol *bp = container_of(this,
+			struct efi_driver_binding_extended_protocol, bp);
 
 	EFI_ENTRY("%p, %p, %zu, %p", this, controller_handle,
 		  number_of_children, child_handle_buffer);
@@ -283,7 +283,7 @@ static efi_status_t efi_add_driver(struct driver *drv)
 	}
 	bp->bp.image_handle = bp->bp.driver_binding_handle;
 	ret = efi_add_protocol(bp->bp.driver_binding_handle,
-			       &efi_guid_driver_binding_protocol, bp);
+			       &efi_guid_driver_binding_protocol, &bp->bp);
 	if (ret != EFI_SUCCESS) {
 		efi_delete_handle(bp->bp.driver_binding_handle);
 		free(bp);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-27  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-27  4:30 [PATCH] efi_driver: fix a wrong cast AKASHI Takahiro
2021-09-27  7:48 ` Heinrich Schuchardt
2021-09-27  8:53   ` AKASHI Takahiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox