New Defects reported by Coverity Scan for Das U-Boot

Masahisa Kojima masahisa.kojima at linaro.org
Mon Jan 22 07:44:20 CET 2024


Hi Heinrich,

On Fri, 19 Jan 2024 at 17:47, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
>
>
> ________________________________________________________________________________________________________
> *** CID 478333:  Error handling issues  (CHECKED_RETURN)
> /lib/efi_loader/efi_firmware.c: 413 in efi_firmware_set_fmp_state_var()
> 407             /*
> 408              * GetVariable may fail, EFI_NOT_FOUND is returned if FmpState
> 409              * variable has not been set yet.
> 410              * Ignore the error here since the correct FmpState variable
> 411              * is set later.
> 412              */
> >>>     CID 478333:  Error handling issues  (CHECKED_RETURN)
> >>>     Calling "efi_get_variable_int" without checking return value (as is done elsewhere 29 out of 33 times).
> 413             efi_get_variable_int(varname, image_type_id, NULL, &size,
> var_state,
> 414                                  NULL);
> 415     416             /*
> 417              * Only the fw_version is set here.
> 418              * lowest_supported_version in FmpState variable is ignored since
>
> There are a lot of different return values that may occur when calling
> efi_get_variable_int, e.g.
>
> * EFI_BUFFER_TOO_SMALL
> * EFI_DEVICE_ERROR
>
> Should we overwrite the variable in these cases with NUL values except
> for var_state[update_bank].fw_version?

The var_state buffer is allocated by calloc(), and efi_get_variable_int()
will not update the buffer in case of error.
But it is better to set NUL values to var_state, I will send a fix.

Thanks,
Masahisa Kojima

>
> Best regards
>
> Heinrich


More information about the U-Boot mailing list