diff options
author | Masahisa Kojima <masahisa.kojima@linaro.org> | 2024-01-29 11:51:14 +0900 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2024-01-29 11:31:44 +0100 |
commit | 21489b4478a72d6c682f24dea80d5ac7790e2692 (patch) | |
tree | c60047ae93c02a1b4a8b80049ed661a73ae3c9da /lib/efi_loader | |
parent | 796469c453325c2778b388ee4bd67f4dc0d16685 (diff) | |
download | u-boot-21489b4478a72d6c682f24dea80d5ac7790e2692.zip u-boot-21489b4478a72d6c682f24dea80d5ac7790e2692.tar.gz u-boot-21489b4478a72d6c682f24dea80d5ac7790e2692.tar.bz2 |
efi_loader: check efi_get_variable_int return value
efi_get_variable_int() may fail, the buffer should be
cleared before using it.
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Addresses-Coverity-ID: 478333 ("Error handling issues")
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/efi_firmware.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 9fd1329..ba5aba0 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -400,18 +400,18 @@ efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in } size = num_banks * sizeof(*var_state); - var_state = calloc(1, size); + var_state = malloc(size); if (!var_state) return EFI_OUT_OF_RESOURCES; /* * GetVariable may fail, EFI_NOT_FOUND is returned if FmpState * variable has not been set yet. - * Ignore the error here since the correct FmpState variable - * is set later. */ - efi_get_variable_int(varname, image_type_id, NULL, &size, var_state, - NULL); + ret = efi_get_variable_int(varname, image_type_id, NULL, &size, + var_state, NULL); + if (ret != EFI_SUCCESS) + memset(var_state, 0, num_banks * sizeof(*var_state)); /* * Only the fw_version is set here. |