mmap(2) failure is indicated by MAP_FAILED, not NULL.
ok mglocker
This commit is contained in:
parent
9d46737716
commit
9df5e43bd2
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: video.c,v 1.15 2016/06/02 07:47:25 mglocker Exp $ */
|
/* $OpenBSD: video.c,v 1.16 2016/06/02 08:53:32 tb Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010 Jacob Meuser <jakemsr@openbsd.org>
|
* Copyright (c) 2010 Jacob Meuser <jakemsr@openbsd.org>
|
||||||
*
|
*
|
||||||
@ -1271,7 +1271,7 @@ mmap_init(struct video *vid)
|
|||||||
}
|
}
|
||||||
vid->mmap_buffer[i] = mmap(0, buf.length, PROT_READ,
|
vid->mmap_buffer[i] = mmap(0, buf.length, PROT_READ,
|
||||||
MAP_SHARED, vid->dev.fd, buf.m.offset);
|
MAP_SHARED, vid->dev.fd, buf.m.offset);
|
||||||
if (vid->mmap_buffer[i] == NULL) {
|
if (vid->mmap_buffer[i] == MAP_FAILED) {
|
||||||
warn("mmap");
|
warn("mmap");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1313,7 +1313,8 @@ mmap_stop(struct video *vid)
|
|||||||
|
|
||||||
/* unmap the buffers */
|
/* unmap the buffers */
|
||||||
for (i = 0; i < MMAP_NUM_BUFS; i++) {
|
for (i = 0; i < MMAP_NUM_BUFS; i++) {
|
||||||
if (vid->mmap_buffer[i] != NULL) {
|
if (vid->mmap_buffer[i] != NULL &&
|
||||||
|
vid->mmap_buffer[i] != MAP_FAILED) {
|
||||||
r = munmap(vid->mmap_buffer[i], vid->bpf);
|
r = munmap(vid->mmap_buffer[i], vid->bpf);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
warn("munmap");
|
warn("munmap");
|
||||||
|
Loading…
Reference in New Issue
Block a user