src/security/tpm: Deal with zero length tlcl writes

While memcpy(foo, bar, 0) should be a no-op, that's hard to prove for a
compiler and so gcc 11.1 complains about the use of an uninitialized
"bar" even though it's harmless in this case.

Change-Id: Idbffa508c2cd68790efbc0b4ab97ae1b4d85ad51
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54095
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Patrick Georgi 2021-05-12 14:54:49 +02:00
parent 40b8f01697
commit 99973d29af
1 changed files with 2 additions and 1 deletions

View File

@ -215,6 +215,7 @@ uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
to_tpm_uint32(cmd.buffer + tpm_nv_write_cmd.index, index);
to_tpm_uint32(cmd.buffer + tpm_nv_write_cmd.length, length);
if (length > 0)
memcpy(cmd.buffer + tpm_nv_write_cmd.data, data, length);
return tlcl_send_receive(cmd.buffer, response, sizeof(response));