freedreno: Fix file descriptor leak.

Fix defect reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_handle: Handle variable fd going out of scope leaks the handle.

Fixes: 5a13507164 ("freedreno/perfcntrs: add fdperf")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9889>
This commit is contained in:
Vinson Lee 2021-03-28 20:24:27 -07:00 committed by Marge Bot
parent ee14bec09a
commit a5d5cbdf08

View file

@ -246,10 +246,9 @@ fd_dt_find_io(void)
return NULL;
void *io = mmap(0, dev.size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, dev.base);
if (io == MAP_FAILED) {
close(fd);
close(fd);
if (io == MAP_FAILED)
return NULL;
}
return io;
}