From patchwork Wed Jan 17 19:15:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 862515 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zMH2432fLz9t4t for ; Thu, 18 Jan 2018 06:18:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EFBC5C21E13; Wed, 17 Jan 2018 19:17:29 +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_MSPIKE_H2 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 8B8F5C21E4E; Wed, 17 Jan 2018 19:16:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4F61EC21DDD; Wed, 17 Jan 2018 19:16:23 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lists.denx.de (Postfix) with ESMTPS id D0690C21DE4 for ; Wed, 17 Jan 2018 19:16:22 +0000 (UTC) Received: from workstation4.fritz.box ([95.222.46.37]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Lp3x6-1f5TJx09Yq-00eqVp; Wed, 17 Jan 2018 20:16:21 +0100 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 17 Jan 2018 20:15:57 +0100 Message-Id: <20180117191612.17108-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180117191612.17108-1-xypron.glpk@gmx.de> References: <20180117191612.17108-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:8P6YX3U/xgVUr0UMp5dnuWClEa8iqbvsmCvjgc7ha2vvjBlu04Z sE+E+5PdBGqMkMR36iAqEPISNKKOF2XpzRZcMIm2haBfvCSxSrk3Piod82pZfKfxDskyrhH 0VEVd/QHX0Ot0ZtFSqdR4TCp2HHhmu6JUu08BsKhcd4ATi6vxlRcRTDLH2WlmXi2+8iZ58I gCjcSm221YjD3qTaEIT4g== X-UI-Out-Filterresults: notjunk:1; V01:K0:9vJHSSSxB4w=:Rk7WsDqrmCOqYtSxpEU3v2 kV9xd67MOe4tmJKI30RulT3YFPdNaMUgoYXFJAe1RY/5LWlZ0UU7pQwJaCYfj7iDNt9g2Thfm cQylk62izixMrjl9cz38rF3QG+sQNLKhiMNzdAzofUvMlTprg45UmEcw2dXw8zrFLAo5jI7wX BWx1oU8evvbxVDUNS0oG8DP+7nWx3NTH1smo2SCAAEhxsAfowwMrXuTkTK+oZNTOTTsxWyDUk JK8Y1kFWIBS/FTi59ufILFZ6iSUHZzAo9zg95ScRZNhW5gkS7SZyZlv3n3gTvXvGRKE1GWjmB wQQkw/e9aJQxcOtuuQuATnmW2j3jkzYWqBAK1Xo78+Dk2HAIUBwJ3mfhHRY0X5QMs2TE2hSoP VLNzyeeyHfv2g1cwDrHCirZZ6dX4BLjaYXJYDqyXpU+3KgP7J+02PyT3JEt1AOYtuj3FZaWrE ZVWs+CHWLRPxmAan6VqyFr4c6y3rTHUOZoNHTwUrNE91EjOpFN+SMf+MqqrnJCP+2rGtENR/j G+BXgxj+ryumDsar+UvN6EjlsJGFM3VEgcR0I8wcZW4XJA1lkodYhynFGnCu0MHHqozppNhQo yoIjokRDrTJ47CdSff/4N6de5mpEN8Uqg2ZGp4KJG0wj/NbW+/IAbnWSafeEK92C4rEsOHEqS ums1HHlc6nIygkGTPDVkUpWSAYs8UAixy93jSnPl+Gk8jNBRFYZIlOzzFG++ng5YNFYuJ/RzD 6hQZmZ+h0CCIWT0LoVLljg6zycKD6VDRq+XGHjyS8hBoA3cmsSkfxrHFknXUlXN99fHC14pvZ roJRqG+egSCl+In6R0G2+BLjNCPbw== Cc: Heinrich Schuchardt , Tom Rini , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 03/18] efi_loader: correct find simple file system protocol 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" In contrast to the description the code did not split the device path into device part and file part. The code should use the installed protocol and not refer to the internal structure of the the disk object. Signed-off-by: Heinrich Schuchardt --- v2 no change --- lib/efi_loader/efi_disk.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 85b4a147e2..8771e880f6 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -175,25 +175,44 @@ static const struct efi_block_io block_io_disk_template = { }; /* - * Find filesystem from a device-path. The passed in path 'p' probably - * contains one or more /File(name) nodes, so the comparison stops at - * the first /File() node, and returns the pointer to that via 'rp'. - * This is mostly intended to be a helper to map a device-path to an - * efi_file_handle object. + * Get the simple file system protocol for a file device path. + * + * The full path provided is split into device part and into a file + * part. The device part is used to find the handle on which the + * simple file system protocol is installed. + * + * @full_path device path including device and file + * @return simple file system protocol */ struct efi_simple_file_system_protocol * -efi_fs_from_path(struct efi_device_path *fp) +efi_fs_from_path(struct efi_device_path *full_path) { struct efi_object *efiobj; - struct efi_disk_obj *diskobj; + struct efi_handler *handler; + struct efi_device_path *device_path; + struct efi_device_path *file_path; + efi_status_t ret; - efiobj = efi_dp_find_obj(fp, NULL); + /* Split the path into a device part and a file part */ + ret = efi_dp_split_file_path(full_path, &device_path, &file_path); + if (ret != EFI_SUCCESS) + return NULL; + efi_free_pool(file_path); + + /* Get the EFI object for the partition */ + efiobj = efi_dp_find_obj(device_path, NULL); + efi_free_pool(device_path); if (!efiobj) return NULL; - diskobj = container_of(efiobj, struct efi_disk_obj, parent); + /* Find the simple file system protocol */ + ret = efi_search_protocol(efiobj, &efi_simple_file_system_protocol_guid, + &handler); + if (ret != EFI_SUCCESS) + return NULL; - return diskobj->volume; + /* Return the simple file system protocol for the partition */ + return handler->protocol_interface; } /*