[Mesa-dev] [PATCH] intel/aubinator: fix resource leak in aub_file_open
Nayan Deshmukh
nayan26deshmukh at gmail.com
Sun Dec 4 17:47:29 UTC 2016
CovID: 1373563
Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
---
src/intel/tools/aubinator.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 5e3a684..f64a843 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -959,25 +959,28 @@ aub_file_open(const char *filename)
fd = open(filename, O_RDONLY);
if (fd == -1) {
fprintf(stderr, "open %s failed: %s\n", filename, strerror(errno));
- exit(EXIT_FAILURE);
+ goto exit_failure;
}
if (fstat(fd, &sb) == -1) {
fprintf(stderr, "stat failed: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
+ goto exit_failure;
}
file->map = mmap(NULL, sb.st_size,
PROT_READ, MAP_SHARED, fd, 0);
if (file->map == MAP_FAILED) {
fprintf(stderr, "mmap failed: %s\n", strerror(errno));
- exit(EXIT_FAILURE);
+ goto exit_failure;
}
file->cursor = file->map;
file->end = file->map + sb.st_size / 4;
return file;
+exit_failure:
+ free(file);
+ exit(EXIT_FAILURE);
}
static struct aub_file *
--
2.9.3
More information about the mesa-dev
mailing list