u-boot/lib/efi_loader
Ilias Apalodimas ad53505a48 efi_loader: Fix a memory leak when retrieving device paths from boot vars
get_dp_device() is used to derive the device path from a boot variable.
However, if the last efi_get_variable_int() call fails, we return an
error without freeing 'buf'.

There's no need to call efi_get_variable_int() for variables we don't
know the size since we have the efi_get_var() wrapper.

Replace that in the two instances we use it. The first one will also
fix the memory leak.
A nice sideeffect is that the code size is also reduced, since we are
re-using functions instead of open coding them

$~ bloat-o-meter u-boot u-boot.new
add/remove: 0/0 grow/shrink: 1/2 up/down: 6/-196 (-190)
Function                                     old     new   delta
version_string                                70      76      +6
efi_launch_capsules                         2288    2196     -92
get_dp_device                                244     140    -104
Total: Before=1222331, After=1222141, chg -0.02%

Fixes: c74cd8bd08d1 ("efi_loader: capsule: add capsule_on_disk support")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-12-06 11:43:28 +01:00
..
2025-05-25 11:27:18 +02:00
2025-04-11 13:25:27 +02:00
2024-01-16 17:05:29 -05:00
2024-09-12 17:35:37 +02:00
2025-07-03 12:26:45 +03:00
2024-11-09 09:59:41 +01:00