Skip to content

Commit

Permalink
Fix file descriptor leak (reported by Coverity)
Browse files Browse the repository at this point in the history
While we really don't care about it and the descriptor will be
closed anyway when the process gets terminated, it's still better
to fix this.
  • Loading branch information
ssvb committed Feb 14, 2017
1 parent a0c5fc2 commit a2d7b42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ static void *mmap_framebuffer(size_t *fbsize)
if ((fd = open("/dev/graphics/fb0", O_RDWR)) == -1)
return NULL;

if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo))
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo)) {
close(fd);
return NULL;
}

p = mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);

if (p == (void *)-1)
return NULL;

Expand Down

0 comments on commit a2d7b42

Please sign in to comment.