diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-07-08 13:25:50 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-07-08 13:25:50 +1000 |
commit | 709f0877f03250f07c47882999851603e3945175 (patch) | |
tree | 21623a92180e5cb1ba7115901ac6a8500f523700 /hdata/pcia.c | |
parent | 810c2e00bb4e0774c1331edc8f50def31efafc49 (diff) | |
download | blackbird-skiboot-709f0877f03250f07c47882999851603e3945175.tar.gz blackbird-skiboot-709f0877f03250f07c47882999851603e3945175.zip |
Fix potential negative loop bound in hdata/pcia.c
HDIF_get_iarray_size could return -1 on failure, so detect that
and somewhat gracefully back out of an awful loop
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hdata/pcia.c')
-rw-r--r-- | hdata/pcia.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/hdata/pcia.c b/hdata/pcia.c index efcfa7c4..4495fbe7 100644 --- a/hdata/pcia.c +++ b/hdata/pcia.c @@ -35,9 +35,11 @@ static unsigned int pcia_index(const void *pcia) static const struct sppcia_cpu_thread *find_tada(const void *pcia, unsigned int thread) { - unsigned int count = HDIF_get_iarray_size(pcia, - SPPCIA_IDATA_THREAD_ARRAY); - unsigned int i; + int count = HDIF_get_iarray_size(pcia, SPPCIA_IDATA_THREAD_ARRAY); + int i; + + if (count < 0) + return NULL; for (i = 0; i < count; i++) { const struct sppcia_cpu_thread *t; |