[PATCH 1/1] efi_driver: don't leak name in efi_bl_create_block_device()
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Wed Nov 5 13:04:22 CET 2025
On 11/5/25 12:08, Bin Meng wrote:
> On Wed, Nov 5, 2025 at 7:22 AM Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
>>
>> In case of an error always free variable name.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>> ---
>> lib/efi_driver/efi_block_device.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
>> index c389b1920a8..7ce6a45a5f3 100644
>> --- a/lib/efi_driver/efi_block_device.c
>> +++ b/lib/efi_driver/efi_block_device.c
>> @@ -146,7 +146,6 @@ efi_bl_create_block_device(efi_handle_t handle, void *interface)
>> devnum, io->media->block_size,
>> (lbaint_t)io->media->last_block, &bdev)) {
>> ret = EFI_OUT_OF_RESOURCES;
>> - free(name);
>> goto err;
>> }
>>
>> @@ -171,6 +170,7 @@ err:
>> efi_unlink_dev(handle);
>> if (bdev)
>> device_unbind(bdev);
>> + free(name);
>>
>> return ret;
>> }
>
> free() should be inserted right after the blk_create_devicef() call as
> the success path also leaks the 'name'.
>
> Regards,
> Bin
I could not see blk_create_devicef() duplicating the device name string.
My understanding is that it should be deleted when deleting the device.
Cc: Simon
Best regards
Heinrich
More information about the U-Boot
mailing list