From: Jens Axboe Date: Mon, 14 Apr 2014 19:20:38 +0000 (-0600) Subject: Fix potential NULL dereference in alloc_mem_mmap() X-Git-Tag: fio-2.1.9~25 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=b3493a7aadd6f36b98075af7ac8bd9e276b4b361 Fix potential NULL dereference in alloc_mem_mmap() Signed-off-by: Jens Axboe --- diff --git a/memory.c b/memory.c index b208320c..8c06d94d 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;