From: Olaf Hering Date: Tue, 22 Jul 2014 07:19:15 +0000 (+0200) Subject: mini-os: tpm: fix array access in locality_enabled X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4608 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=52bdfeacbb601da2d66b5b1dde159b973ee8b309;p=xen.git mini-os: tpm: fix array access in locality_enabled 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 Acked-by: Samuel Thibault --- diff --git a/extras/mini-os/tpm_tis.c b/extras/mini-os/tpm_tis.c index e8ca69f912..dc4134a161 100644 --- a/extras/mini-os/tpm_tis.c +++ b/extras/mini-os/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) {