diff --git a/fs/mmap/fs_rammap.c b/fs/mmap/fs_rammap.c index d25458ff42..401eaa02af 100644 --- a/fs/mmap/fs_rammap.c +++ b/fs/mmap/fs_rammap.c @@ -78,7 +78,7 @@ static int msync_rammap(FAR struct mm_map_entry_s *entry, FAR void *start, fpos = file_seek(filep, entry->offset + offset, SEEK_SET); if (fpos < 0) { - ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos); + ferr("ERROR: Seek to position %"PRIdOFF" failed\n", fpos); return fpos; } @@ -109,7 +109,15 @@ static int msync_rammap(FAR struct mm_map_entry_s *entry, FAR void *start, /* Restore file pos */ - file_seek(filep, opos, SEEK_SET); + fpos = file_seek(filep, opos, SEEK_SET); + if (fpos < 0) + { + /* Ensure that we finally seek back to the current file pos */ + + ferr("ERROR: Seek back to position %"PRIdOFF" failed\n", fpos); + return fpos; + } + return nwrite >= 0 ? 0 : nwrite; }