From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E290C433EF for ; Mon, 27 Sep 2021 04:31:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7F3D60F92 for ; Mon, 27 Sep 2021 04:31:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D7F3D60F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C827832C4; Mon, 27 Sep 2021 06:31:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="flh4Xwwn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EB0F83457; Mon, 27 Sep 2021 06:31:14 +0200 (CEST) Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1EFD683230 for ; Mon, 27 Sep 2021 06:31:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x429.google.com with SMTP id n23so11795242pfv.4 for ; Sun, 26 Sep 2021 21:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dHIGMxyzG7zjkJ0xX289xJnwBCwy7I7XTn8/ojJ3qH4=; b=flh4XwwnbfYQBClv6hO9pgVu8rVLcmH4v42y2WwrRwL7enRO+JiBPeP32ICNXv17uB ZwY7h04u587kSTFxqGqWUvHqgz0KZmx+ENZR2Gc4KtWme0QC4BnWqzmEcprPJvJwhSVB 56m99hPEqZ7Q1r0APVtSFBduJmLif+NxUp0xGkbgY5fUcq54ZfZ3eC7kwPyXMSGqXtiq k+5r0SrPjPokVKARxoAw3hVZdLMu806aGu6Z4I3FRRvMydx7mZTkWd62vF0Ew2FFW6Ls 7xADIWnRVjgiVw+sgqjaG3jxHrDxpixPcrznQ3x4p3EL8i2IcaJANMOZYOGbajm9d7iZ cROQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dHIGMxyzG7zjkJ0xX289xJnwBCwy7I7XTn8/ojJ3qH4=; b=NtA2fCnICMDMMWmElYopQsgdrfUTVlefv3+mSX2kk7WmFBVAdsLAf6AkJ9FT+kpnQy om7O3XxE20AxBIyIKmBk9d6QN1hMVLfERIs0fn1w/ggm0xOsZ5oKJ48su6Vjnf+1nFCv vr9sEId9iehwVw6bP0qBZv7Cmd/Wp7JrMNpErwCXckZrZ0MKhbG6ZiEypxMcprdQrPZ6 TvfC5JXdlzNv9usvns6o1yRFiqZh+2kLoVXSqcf6RtEwA5uoGb7x9igSEplhl8Tfc8oG hb+IOEx1Aje//Rb2+WQtCmnUP4Av7zvhTvEKWKtxK6R4E8tdH5ZZzyPOXgGYIPLE905w zoBQ== X-Gm-Message-State: AOAM532HcW+E8YwLngJcLGkNC75Zzpoe/W/N5pITAfcAZ1zc8dbUadD2 jZ+txNsCYCE+tP7gKCd4OMrTuQ== X-Google-Smtp-Source: ABdhPJx5DmeBoqWwyISaJzdVlxPQJX3yFBUb+OrV2ypgrdbkFCUkHVFkmifHcQXpZtV/G4JZZK20Xw== X-Received: by 2002:aa7:80d9:0:b029:2ed:49fa:6dc5 with SMTP id a25-20020aa780d90000b02902ed49fa6dc5mr21728165pfn.3.1632717069175; Sun, 26 Sep 2021 21:31:09 -0700 (PDT) Received: from localhost.localdomain (p6e421539.tkyea130.ap.so-net.ne.jp. [110.66.21.57]) by smtp.gmail.com with ESMTPSA id l18sm6666445pfu.202.2021.09.26.21.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 21:31:08 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH] efi_driver: fix a wrong cast Date: Mon, 27 Sep 2021 13:30:54 +0900 Message-Id: <20210927043054.32727-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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