From patchwork Wed Jul 5 16:18:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 784718 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3x2mLl18ztz9s71 for ; Thu, 6 Jul 2017 02:20:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 19D72C21EC9; Wed, 5 Jul 2017 16:20:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 28AF0C21E4C; Wed, 5 Jul 2017 16:20:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5F91FC21E5B; Wed, 5 Jul 2017 16:20:16 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id 5EA29C21E27 for ; Wed, 5 Jul 2017 16:20:15 +0000 (UTC) Received: from workstation4.fritz.box ([88.152.145.149]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0M0xbD-1dhaFp45K3-00v9RR; Wed, 05 Jul 2017 18:19:31 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 5 Jul 2017 18:18:50 +0200 Message-Id: <20170705161855.20124-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170705161855.20124-1-xypron.glpk@gmx.de> References: <20170705161855.20124-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:AIjMCP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cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 4/9] efi_loader: implement UninstallProtocolInterface X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Without the patch efi_uninstall_protocol_interface always returns an error. With the patch protocols without interface can be uninstalled. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 7596f16b84..b3a59b4219 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -369,8 +369,41 @@ static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle, efi_guid_t *protocol, void *protocol_interface) { + struct list_head *lhandle; + int i; + efi_status_t r = EFI_NOT_FOUND; + EFI_ENTRY("%p, %p, %p", handle, protocol, protocol_interface); - return EFI_EXIT(EFI_NOT_FOUND); + + if (!handle || !protocol) { + r = EFI_INVALID_PARAMETER; + goto out; + } + + list_for_each(lhandle, &efi_obj_list) { + struct efi_object *efiobj; + efiobj = list_entry(lhandle, struct efi_object, link); + + if (efiobj->handle != handle) + continue; + + for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { + struct efi_handler *handler = &efiobj->protocols[i]; + const efi_guid_t *hprotocol = handler->guid; + if (!guidcmp(hprotocol, protocol)) { + if (handler->protocol_interface) { + r = EFI_ACCESS_DENIED; + } else { + handler->guid = 0; + r = EFI_SUCCESS; + } + goto out; + } + } + } + +out: + return EFI_EXIT(r); } static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol, @@ -811,7 +844,7 @@ static efi_status_t EFIAPI efi_open_protocol( struct efi_handler *handler = &efiobj->protocols[i]; const efi_guid_t *hprotocol = handler->guid; if (!hprotocol) - break; + continue; if (!guidcmp(hprotocol, protocol)) { if (attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {