From a2d7b42ac01fd02fbf674b058be5c6dd4ae5090c Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Tue, 14 Feb 2017 22:54:25 +0200 Subject: [PATCH] Fix file descriptor leak (reported by Coverity) 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. --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index a080f5b..de632cb 100644 --- a/main.c +++ b/main.c @@ -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;