]> xenbits.xensource.com Git - people/liuw/mini-os.git/commitdiff
mini-os: tpm: fix array access in locality_enabled
authorOlaf Hering <olaf@aepfle.de>
Tue, 22 Jul 2014 07:19:15 +0000 (09:19 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 24 Jul 2014 15:23:18 +0000 (16:23 +0100)
gcc-4.3 fails to prove that array indices will remain positive. Add a
hint for the compiler and check the index value before using it.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
tpm_tis.c

index e8ca69f912776ab2f1551e64fbd97681f2a4639a..dc4134a161899763eea5a09b12bc5bc7d4e5ed86 100644 (file)
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -611,7 +611,7 @@ s_time_t tpm_calc_ordinal_duration(struct tpm_chip *chip,
 
 
 static int locality_enabled(struct tpm_chip* tpm, int l) {
-   return tpm->enabled_localities & (1 << l);
+   return l >= 0 && tpm->enabled_localities & (1 << l);
 }
 
 static int check_locality(struct tpm_chip* tpm, int l) {