summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-04-14 13:20:38 -0600
committerJens Axboe <axboe@fb.com>2014-04-14 13:20:38 -0600
commitb3493a7aadd6f36b98075af7ac8bd9e276b4b361 (patch)
treed7763188212627663dff7023d8105d840c7314d6 /memory.c
parent9edf7b3ed581a61433ad620d457b4d0349115e52 (diff)
Fix potential NULL dereference in alloc_mem_mmap()
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/memory.c b/memory.c
index b208320..8c06d94 100644
--- a/memory.c
+++ b/memory.c
@@ -158,9 +158,10 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
if (td->orig_buffer == MAP_FAILED) {
td_verror(td, errno, "mmap");
td->orig_buffer = NULL;
- if (td->mmapfd) {
+ if (td->mmapfd != 1) {
close(td->mmapfd);
- unlink(td->o.mmapfile);
+ if (td->o.mmapfile)
+ unlink(td->o.mmapfile);
}
return 1;