From: Liam Merwick <liam.merwick@oracle.com>
To: stefanb@linux.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 2/3] tpm_tis: assert valid addr passed to tpm_tis_locality_from_addr()
Date: Mon, 11 Feb 2019 15:03:04 +0000 [thread overview]
Message-ID: <1549897385-10091-2-git-send-email-liam.merwick@oracle.com> (raw)
In-Reply-To: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com>
Defensive check to prevent future caller passing incorrect address
or catch if the MMIO address parameters were not all changed together.
Signed-off-by: Liam Merwick <Liam.Merwick@oracle.com>
---
I've been running static analysis tools on QEMU and one reports this check.
While it's just theoretically correct (impossible to hit with current code),
fixing this helps minimise noise and find other issues using those static
analyzers as well as defending against the addition of future bugs.
hw/tpm/tpm_tis.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 61a130beef35..860c2ace7d99 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -100,6 +100,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
static uint8_t tpm_tis_locality_from_addr(hwaddr addr)
{
+ assert(addr < TPM_TIS_ADDR_SIZE);
return (uint8_t)((addr >> TPM_TIS_LOCALITY_SHIFT) & 0x7);
}
--
1.8.3.1
next prev parent reply other threads:[~2019-02-11 15:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 15:03 [Qemu-devel] [PATCH v2 1/3] tpm_tis: fix loop that cancels any seizure by a lower locality Liam Merwick
2019-02-11 15:03 ` Liam Merwick [this message]
2019-02-12 17:29 ` [Qemu-devel] [PATCH v2 2/3] tpm_tis: assert valid addr passed to tpm_tis_locality_from_addr() Stefan Berger
2019-02-11 15:03 ` [Qemu-devel] [PATCH v2 3/3] tpm_tis: fix format string specifier in tpm_tis_show_buffer() Liam Merwick
2019-02-11 16:02 ` Philippe Mathieu-Daudé
2019-02-11 19:56 ` Stefan Berger
2019-02-11 20:09 ` Liam Merwick
2019-02-11 21:13 ` Stefan Berger
2019-02-12 12:31 ` Philippe Mathieu-Daudé
2019-02-12 13:27 ` Stefan Berger
2019-02-12 13:43 ` Liam Merwick
2019-02-12 14:32 ` Philippe Mathieu-Daudé
2019-02-12 12:02 ` Stefan Berger
2019-02-11 20:53 ` [Qemu-devel] [PATCH v2 1/3] tpm_tis: fix loop that cancels any seizure by a lower locality Stefan Berger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1549897385-10091-2-git-send-email-liam.merwick@oracle.com \
--to=liam.merwick@oracle.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).