Skip to content
Snippets Groups Projects
Commit 07836345 authored by Heinrich Schuchardt's avatar Heinrich Schuchardt Committed by Alexander Graf
Browse files

efi_loader: fix AppendDevicePath


The logic of the AppendDevicePath service of the
EFI_DEVICE_PATH_UTILITIES_PROTOCOL is incorrectly implemented:

* if both paths are NULL an end node has to be returned
* if both paths are not NULL the end node of the second device path has to
  be kept

Signed-off-by: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent 211314c1
No related branches found
No related tags found
No related merge requests found
...@@ -263,7 +263,10 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1, ...@@ -263,7 +263,10 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1,
{ {
struct efi_device_path *ret; struct efi_device_path *ret;
if (!dp1) { if (!dp1 && !dp2) {
/* return an end node */
ret = efi_dp_dup(&END);
} else if (!dp1) {
ret = efi_dp_dup(dp2); ret = efi_dp_dup(dp2);
} else if (!dp2) { } else if (!dp2) {
ret = efi_dp_dup(dp1); ret = efi_dp_dup(dp1);
...@@ -275,8 +278,8 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1, ...@@ -275,8 +278,8 @@ struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1,
if (!p) if (!p)
return NULL; return NULL;
memcpy(p, dp1, sz1); memcpy(p, dp1, sz1);
memcpy(p + sz1, dp2, sz2); /* the end node of the second device path has to be retained */
memcpy(p + sz1 + sz2, &END, sizeof(END)); memcpy(p + sz1, dp2, sz2 + sizeof(END));
ret = p; ret = p;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment