Skip to contentSkip to conversation

efi_loader: fix efi_http_instance free on error

PATCH In review Vincent Stehlé 2 participants 2 messages Sep 14 – Sep 17

lore
Share & tools
lore
#0 lore raw

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.

Fixes 238e0269d82f ("efi_loader: efi_net: add EFI_HTTP_PROTOCOL")
Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Tom Rini <[email protected]>
Cc Adriano Cordova <[email protected]>
---
 lib/efi_loader/efi_http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_http.c +1 -1
index 2a606aa441e..d26b2119d6f 100644
@@ -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.
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Vincent Stehlé

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.

Quoted 7 lines
Fixes 238e0269d82f ("efi_loader: efi_net: add EFI_HTTP_PROTOCOL")
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
index 2a606aa441e..d26b2119d6f 100644
@@ -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,
--
Vincent.