Mesa (staging/20.0): freedreno/perfcntrs: fix fd leak
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 5 17:05:47 UTC 2020
Module: Mesa
Branch: staging/20.0
Commit: e163a399942a929bcf1b9f3c53f6750e2fcf270b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e163a399942a929bcf1b9f3c53f6750e2fcf270b
Author: Eric Engestrom <eric at engestrom.ch>
Date: Sun Feb 2 17:04:29 2020 +0000
freedreno/perfcntrs: fix fd leak
CoverityID: 1110568, 1458071
Fixes: 5a13507164a26fc796f0 ("freedreno/perfcntrs: add fdperf")
Signed-off-by: Eric Engestrom <eric at 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>
(cherry picked from commit cae609326678bd00702261f756ce0c16efd530d4)
---
.pick_status.json | 2 +-
src/freedreno/perfcntrs/fdperf.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index f87b5f0f462..78418eea96f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -337,7 +337,7 @@
"description": "freedreno/perfcntrs: fix fd leak",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "5a13507164a26fc796f02c57a24468b834254b4d"
},
diff --git a/src/freedreno/perfcntrs/fdperf.c b/src/freedreno/perfcntrs/fdperf.c
index afebc3830df..f6bb4f00f06 100644
--- a/src/freedreno/perfcntrs/fdperf.c
+++ b/src/freedreno/perfcntrs/fdperf.c
@@ -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");
+ }
}
/*
More information about the mesa-commit
mailing list