Message ID | 1550004500-24485-2-git-send-email-liam.merwick@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3,1/3] tpm_tis: fix loop that cancels any seizure by a lower locality | expand |
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 61a130beef35..772431f20874 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -100,7 +100,9 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr, static uint8_t tpm_tis_locality_from_addr(hwaddr addr) { - return (uint8_t)((addr >> TPM_TIS_LOCALITY_SHIFT) & 0x7); + uint8_t locty = (uint8_t)(addr >> TPM_TIS_LOCALITY_SHIFT); + assert(TPM_TIS_IS_VALID_LOCTY(locty)); + return locty; } static void tpm_tis_show_buffer(const unsigned char *buffer,
Assert that the address passed in results in a valid locality value. Current callers pass a valid address so this is just a defensive check to prevent a future caller passing an incorrect address or catch if the MMIO address parameters were not all modified correctly. This is to help static code analysis tools that report that no explicit checking is being done. Signed-off-by: Liam Merwick <Liam.Merwick@oracle.com> --- hw/tpm/tpm_tis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)