diff options
author | Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> | 2015-07-03 15:54:04 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-07-07 10:36:29 +1000 |
commit | 529cbf85745f6a99d44eacf76e0d9206af316979 (patch) | |
tree | a26640c1331acc6a7b2899a4b7f01feae62d1765 | |
parent | b9c9f77cfd68ebd2a23f45453ef3f64ff031d538 (diff) | |
download | skiboot-529cbf85745f6a99d44eacf76e0d9206af316979.zip skiboot-529cbf85745f6a99d44eacf76e0d9206af316979.tar.gz skiboot-529cbf85745f6a99d44eacf76e0d9206af316979.tar.bz2 |
hdata test: Check the return value from lseek
Check if value returned by lseek is non-negative, as we
will be passing it mmap. Fix it up, by aborting on negative
value.
Fixes Coverity defect#98808.
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
[stewart@linux.vnet.ibm.com: fix spira_heap_size type]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | hdata/test/hdata_to_dt.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c index 64749eb..96c9953 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -29,7 +29,7 @@ struct dt_node *opal_node; /* Our actual map. */ static void *spira_heap; -static size_t spira_heap_size; +static off_t spira_heap_size; static uint64_t base_addr; /* Override ntuple_addr. */ @@ -195,6 +195,8 @@ int main(int argc, char *argv[]) if (fd < 0) err(1, "opening %s", argv[2]); spira_heap_size = lseek(fd, 0, SEEK_END); + if (spira_heap_size < 0) + err(1, "lseek on %s", argv[2]); spira_heap = mmap(NULL, spira_heap_size, PROT_READ, MAP_SHARED, fd, 0); if (spira_heap == MAP_FAILED) err(1, "mmaping %s", argv[3]); |