[PATCH] efi_driver: fix a wrong cast
AKASHI Takahiro
takahiro.akashi at linaro.org
Mon Sep 27 06:30:54 CEST 2021
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 at 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
More information about the U-Boot
mailing list