summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/intelvbttool/intelvbttool.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/util/intelvbttool/intelvbttool.c b/util/intelvbttool/intelvbttool.c
index 31fc24a2e0..f0216dd207 100644
--- a/util/intelvbttool/intelvbttool.c
+++ b/util/intelvbttool/intelvbttool.c
@@ -515,13 +515,20 @@ int main(int argc, char **argv)
{
const void *ptr;
int fd;
+ off_t offset;
if (argc == 2) {
fd = open(argv[1], O_RDONLY);
- ptr = mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0);
+ offset = 0;
} else {
fd = open("/dev/mem", O_RDONLY);
- ptr = mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0xc0000);
+ offset = 0xc0000;
}
+ if (fd < 0) {
+ fprintf(stderr, "open failed: %s\n", strerror(errno));
+ return 1;
+ }
+
+ ptr = mmap(0, 65536, PROT_READ, MAP_SHARED, fd, offset);
if (ptr == MAP_FAILED) {
fprintf(stderr, "mmap failed: %s\n", strerror(errno));
return 1;