summaryrefslogtreecommitdiff
path: root/src/security
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2021-05-12 14:54:49 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-05-13 18:34:51 +0000
commit99973d29af774c54e8859d967b2b9617abebeeb0 (patch)
treef53ff68408dcec6ee27251c4d043c42ab03bfaf3 /src/security
parent40b8f01697d6f26f86de7fbda1d0a160dcd4d5df (diff)
downloadcoreboot-99973d29af774c54e8859d967b2b9617abebeeb0.tar.xz
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>
Diffstat (limited to 'src/security')
-rw-r--r--src/security/tpm/tss/tcg-1.2/tss.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c
index 8b7778ddb2..413b68193f 100644
--- a/src/security/tpm/tss/tcg-1.2/tss.c
+++ b/src/security/tpm/tss/tcg-1.2/tss.c
@@ -215,7 +215,8 @@ 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);
- memcpy(cmd.buffer + tpm_nv_write_cmd.data, data, length);
+ if (length > 0)
+ memcpy(cmd.buffer + tpm_nv_write_cmd.data, data, length);
return tlcl_send_receive(cmd.buffer, response, sizeof(response));
}