This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1935ea64604 fs/mmap: drop file reference when ram map add fails
1935ea64604 is described below
commit 1935ea646049295a1b069aa2b11659887d7c2516
Author: chao an <[email protected]>
AuthorDate: Wed Oct 21 13:46:09 2026 +0800
fs/mmap: drop file reference when ram map add fails
rammap() takes an extra reference on the backing file before adding the
mapping entry to the current memory map. If mm_map_add() fails, the
mapping entry is discarded through the region cleanup path, but the extra
file reference was not released.
Drop the file reference before freeing the allocated mapping region when
mm_map_add() fails.
Signed-off-by: chao an <[email protected]>
---
fs/mmap/fs_rammap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c
index 2ed0cf490b0..eead13397e5 100644
--- a/fs/mmap/fs_rammap.c
+++ b/fs/mmap/fs_rammap.c
@@ -352,6 +352,7 @@ out:
ret = mm_map_add(get_current_mm(), entry);
if (ret < 0)
{
+ file_put(filep);
goto errout_with_region;
}