From patchwork Tue Jul 11 20:06:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 786843 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 3x6YC90Czyz9s81 for ; Wed, 12 Jul 2017 06:12:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CA88AC21DF3; Tue, 11 Jul 2017 20:10:14 +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 0D508C21EA6; Tue, 11 Jul 2017 20:08:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 56BC5C21EF3; Tue, 11 Jul 2017 20:07:38 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lists.denx.de (Postfix) with ESMTPS id EB0D0C21EA6 for ; Tue, 11 Jul 2017 20:07:32 +0000 (UTC) Received: from workstation4.fritz.box ([88.152.145.149]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MK0Np-1dTdqi2PRd-001RY7; Tue, 11 Jul 2017 22:06:37 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Tue, 11 Jul 2017 22:06:17 +0200 Message-Id: <20170711200625.7108-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170711200625.7108-1-xypron.glpk@gmx.de> References: <20170711200625.7108-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:ESIKSwKUj2aTkaMqVbZTejisryoCmiBN0EXMce6LmGqoCvhO1UA CPk3IFee8wV7MQlBTQmGU8UZzhZ03/yKrw7zUw0uI/CaZi9xiN3BbwpuovBrOTzdJKI0Psx 8uO5s8IatNWUotJ1HV5JmqDlt7uqSYZ6TFUKjB6f38B7WA5ssYiwP+0Ff2Y9kBb8spImdcD aL7HaT/Cw7Z0b1BK3sBLQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:5lnhdlRLpyo=:m49ACYpfWHK2QvYJi5UhAP WeX54IPdjB1Ax6MoRJA4GRLoLmq0ApHLC60TpcI47mQciL4kwQWaPRTEqVzpaHheJXolyT3Ub M08Q8AJ9EIVF3mzFTPkW38usbvzXEKZfLhimBzty7WGvvEajlHpb6zrsnFQSnvh72oyXer8Gn EtKsmsYaK9c6HfKxHlpr07QbO1CC5KGBK44MiuvsHNCOQTlbytH00ju/EUwGopehbvepTfJJg niU40APwvajBg4I0z0dPl1so7pmloKbzp0+D6DiRLoU2dQla8uvMdwZ1V1DhS3WNYOquBW9As KWbZKokrRNXWJoOEJIImaFxiCqM9RtrlyC0gDnWFdld63tYGQinSpIRlauNCD+THGh8fZ5MRy IPhZAM0oPr+FJkaIMtgBf0erDKc6dNBY/1fenMr9ggPhrq08elDOILJPEyciGtPBAGWLI9t/m lwPfuDBFP10m/70OCFyaTUuLCADttQ6bS4F6IQAUqClSfW44RjUoMYJA96Hxh/6ocUE43GjIt tOkLWwYe0VTM61fOxOBdAR+g7Vhupd9WJIM10TND/NCKhh/dna1M5T9O18WMUurD6rPDvYI1a T9UOFuu7oQzY262Pn2xnNYjobqafAooh/uqRppkvv7y5gQscDzB1BJadCdMdUz6z4sQ0Ek5m7 GWVh2rsY6Cz8iTiTOif/RL3tQ+TdGNgW+e8zZsAihAxIFuRIr3MtxtuSsa+L7g6mC4FnmMqzm mDXg52xV62PKp3ER6sW1g1LOghy5AvC7KPsOF5LjWaxb9AiuEEngKcgyshA= Cc: Heinrich Schuchardt , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 04/12] 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 --- v2 Check if protocol != NULL to avoid illegal memory access. --- lib/efi_loader/efi_boottime.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 97b2dce8b3..6c64b94e4a 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -372,8 +372,44 @@ 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 (!hprotocol) + continue; + 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, @@ -814,7 +850,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) {