host: Fix compilation error with GCC

This commit addresses an issue with variable initialization in the
vb21_sign_data() function introduced by commit ab654c4a5829 ("vb21: load
private key before signing"). When the vb_keyb_from_private_key function
fails, the code jumps to the done label, which attempts to free buf that
was not declared nor assigned at the time of the jump.

By declaring and initializing the buf variable alongside sig_digest, the
following compilation error and potential runtime issues are being
addressed:

    host/lib21/host_signature.c:207:17: error: 'buf' may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
    207 | free(buf);
        | ^~~~~~~~~

BUG=b:414365647
TEST=Successful build with GCC

Change-Id: I1f950d4bb8835edd67de4589553a2cdee19d2397
Signed-off-by: Jeremy Compostella <[email protected]>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/6495788
Reviewed-by: Zhixing Ma <[email protected]>
Reviewed-by: Yu-Ping Wu <[email protected]>
Tested-by: Zhixing Ma <[email protected]>
Commit-Queue: Yu-Ping Wu <[email protected]>
Reviewed-by: Grzegorz Bernacki <[email protected]>
Reviewed-by: Wonkyu Kim <[email protected]>
Reviewed-by: Benjamin Shai <[email protected]>
1 file changed
OSZAR »