diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c index 09cf000df8..e1ee0ee89f 100644 --- a/fs/mmap/fs_mmap.c +++ b/fs/mmap/fs_mmap.c @@ -286,7 +286,11 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags, ret = file_mmap_(filep, start, length, prot, flags, offset, MAP_USER, &mapped); - fs_putfilep(filep); + if (filep) + { + fs_putfilep(filep); + } + if (ret < 0) { goto errout;