freedreno/perfcntrs: fix fd leak

CoverityID: 1110568, 1458071
Fixes: 5a13507164 ("freedreno/perfcntrs: add fdperf")
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3671>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3671>
This commit is contained in:
Eric Engestrom 2020-02-02 17:04:29 +00:00 committed by Marge Bot
parent 8a2c507a8a
commit cae6093266
1 changed files with 5 additions and 1 deletions

View File

@ -123,10 +123,12 @@ readfile(const char *path, int *sz)
if (ret < 0) {
free(buf);
*sz = 0;
close(fd);
return NULL;
} else if (ret < CHUNKSIZE) {
n += ret;
*sz = n;
close(fd);
return buf;
} else {
n += CHUNKSIZE;
@ -393,8 +395,10 @@ find_device(void)
err(1, "could not open /dev/mem");
dev.io = mmap(0, dev.size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, dev.base);
if (!dev.io)
if (!dev.io) {
close(fd);
err(1, "could not map device");
}
}
/*