[PATCH master 13/39] efi: loader: fix memory leak in efi_dp_split_file_path
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 16 00:44:13 PST 2026
When efi_dp_dup(p) fails to duplicate the file path portion, the
function returns EFI_OUT_OF_RESOURCES without freeing the already
duplicated device path 'dp'.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/loader/devicepath.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/efi/loader/devicepath.c b/efi/loader/devicepath.c
index 17c659e4c5d8..a12ab24caaa1 100644
--- a/efi/loader/devicepath.c
+++ b/efi/loader/devicepath.c
@@ -465,8 +465,10 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
goto out;
}
fp = efi_dp_dup(p);
- if (!fp)
+ if (!fp) {
+ free(dp);
return EFI_OUT_OF_RESOURCES;
+ }
p->type = DEVICE_PATH_TYPE_END;
p->sub_type = DEVICE_PATH_SUB_TYPE_END;
p->length = sizeof(*p);
--
2.47.3
More information about the barebox
mailing list