From: Heinrich Schuchardt Date: Tue, 16 Apr 2019 06:44:44 +0200 Subject: [U-Boot] [RFC v3 01/10] efi_loader: device_path: handle special case of loading In-Reply-To: <20190416042428.5007-2-takahiro.akashi@linaro.org> References: <20190416042428.5007-1-takahiro.akashi@linaro.org> <20190416042428.5007-2-takahiro.akashi@linaro.org> Message-ID: <36af606e-d33b-e6b7-736e-68f97bce234a@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 4/16/19 6:24 AM, AKASHI Takahiro wrote: > This is a preparatory patch. > > efi_dp_split_file_path() is used to create device_path and file_path > from file_path for efi_setup_loaded_image(). > In a special case, however, of HARDWARE_DEVICE/MEMORY, it doesn't > work expectedly since this path doesn't contain any FILE_PATH sub-type. > > This patch makes a workaround. > > Signed-off-by: AKASHI Takahiro > --- > lib/efi_loader/efi_device_path.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c > index 53b40c8c3c2d..e283fad767ed 100644 > --- a/lib/efi_loader/efi_device_path.c > +++ b/lib/efi_loader/efi_device_path.c > @@ -933,6 +933,14 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, > dp = efi_dp_dup(full_path); > if (!dp) > return EFI_OUT_OF_RESOURCES; > + > + if (EFI_DP_TYPE(dp, HARDWARE_DEVICE, MEMORY)) { > + /* no FILE_PATH */ > + *device_path = dp; > + > + return EFI_SUCCESS; > + } > + > p = dp; > while (!EFI_DP_TYPE(p, MEDIA_DEVICE, FILE_PATH)) { > p = efi_dp_next(p); > Should we really give device paths *starting* with a memory node a special treatment? Or should we simply handle all cases where the device path does not end on a file path the same, e.g.: diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index d8c052d6ec..d0fd154f54 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -924,7 +924,7 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, struct efi_device_path **device_path, struct efi_device_path **file_path) { - struct efi_device_path *p, *dp, *fp; + struct efi_device_path *p, *dp, *fp = NULL; *device_path = NULL; *file_path = NULL; @@ -935,7 +935,7 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, while (!EFI_DP_TYPE(p, MEDIA_DEVICE, FILE_PATH)) { p = efi_dp_next(p); if (!p) - return EFI_INVALID_PARAMETER; + goto out; } fp = efi_dp_dup(p); if (!fp) @@ -944,6 +944,7 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, p->sub_type = DEVICE_PATH_SUB_TYPE_END; p->length = sizeof(*p); +out: *device_path = dp; *file_path = fp; return EFI_SUCCESS; I would prefer to go for the more generic version. Best regards Heinrich