Fix potential NULL dereference in alloc_mem_mmap()