From c9148fbb0a3186e3efc23367cc2b5041f2fddf7f Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Wed, 19 Jun 2024 18:20:43 +0800 Subject: [PATCH] fs_msync:Fix crash caused under the anonymous mapping Summary: Limitations of using fs putfile Signed-off-by: chenrun1 --- fs/mmap/fs_mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;