efi_loader: fix efi_http_instance free on error
PATCH 1/1 efi_loader: fix efi_http_instance free on error
The new_instance efi_http_instance structure is allocated with calloc(), but it is erroneously freed with efi_free_pool() on the error path.
This can be verified on the sandbox by modifying the code to force the allocation of new_instance->handle to fail, and with the following command:
./u-boot -T -c 'setenv efi_selftest http protocol; bootefi selftest'
This results in the following error message:
efi_free_pool: illegal free 0x000000001928d470
Fix this by using free() instead.
--- lib/efi_loader/efi_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_http.c +1 -1
@@ -404,7 +404,7 @@ static efi_status_t EFIAPI efi_http_service_binding_create_child( new_instance->handle =calloc (1 ,sizeof (struct efi_object ));if (!new_instance->handle) { -efi_free_pool ((void *)new_instance); +free (new_instance); ret =EFI_OUT_OF_RESOURCES ; goto failure_to_add_protocol; }
---
base-commit: a44f46af0aa17e48572e0d46c0d082886ee353c3
change-id: 20260914-crazy-972d7c92a81b
Best regards,
Signature · 1 line
Vincent.
Quoted 16 lines · Vincent Stehlé
The
new_instanceefi_http_instancestructure is allocated withcalloc(), but it is erroneously freed withefi_free_pool()on the error path.This can be verified on the sandbox by modifying the code to force the allocation of
new_instance->handleto fail, and with the following command:./u-boot -T -c 'setenv
efi_selftesthttp protocol; bootefi selftest'This results in the following error message:
efi_free_pool: illegal free0x000000001928d470Fix this by using
free()instead.
Quoted 7 lines
Fixes 238e0269d82f ("efi_loader: efi_net: add EFI_HTTP_PROTOCOL")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Tom Rini <[email protected]>Cc Adriano Cordova <[email protected]>---
Quoted 25 lines
lib/efi_loader/efi_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/efi_loader/efi_http.c +1
-2@@ -404,7 +404,7 @@ static efi_status_t EFIAPI efi_http_service_binding_create_child( new_instance->handle =calloc (1 ,sizeof (struct efi_object ));if (!new_instance->handle) { -efi_free_pool ((void *)new_instance); +free (new_instance); ret =EFI_OUT_OF_RESOURCES ; goto failure_to_add_protocol; } ---base-commit:
a44f46af0aa17e48572e0d46c0d082886ee353c3
change-id: 20260914-crazy-972d7c92a81bBest regards,
--
Vincent.