This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI 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 5c8f439d306 fs/mmap: reject rammap when restoring the file position 
fails
5c8f439d306 is described below

commit 5c8f439d30620359476d9f40fa0e5d4bf5fde1f9
Author: jingfei <[email protected]>
AuthorDate: Fri Nov 27 20:08:08 2026 +0800

    fs/mmap: reject rammap when restoring the file position fails
    
    Propagate a failed position restore after copying file data and release
    the temporary region before retaining the file or registering a mapping.
    
    Signed-off-by: jingfei <[email protected]>
---
 fs/mmap/fs_rammap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c
index 4cbda14856d..6a57f52cc0a 100644
--- a/fs/mmap/fs_rammap.c
+++ b/fs/mmap/fs_rammap.c
@@ -372,7 +372,12 @@ int rammap(FAR struct file *filep, FAR struct 
mm_map_entry_s *entry,
   /* Zero any memory beyond the amount read from the file */
 
   memset(rdbuffer, 0, length);
-  file_seek(filep, opos, SEEK_SET);
+  fpos = file_seek(filep, opos, SEEK_SET);
+  if (fpos < 0)
+    {
+      ret = fpos;
+      goto errout_with_region;
+    }
 
   /* Add the buffer to the list of regions */
 

Reply via email to