RTEMS | dosfs: Avoid FAT file cache update after failed write (!1346)

Yang Zhang (@Chloe) gitlab at rtems.org
Thu Jul 9 01:19:04 UTC 2026



Yang Zhang created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1346

Project:Branches: Chloe/rtems:fix-dosfs-write-cache to rtems/rtos/rtems:main
Author:   Yang Zhang



## Summary

In fat_file_write_fat32_or_non_root_dir(), the FAT file cache was updated even if the first fat_cluster_write() failed and no bytes were completed.

\
In that case, cmpltd remains zero, so the expression using cmpltd - 1 may underflow and the cache may be updated with an invalid file cluster or disk cluster mapping.

Only update the cache if at least one byte was successfully written.

## Generative AI

<!--If you have used AI please use the "AI Contribution" template otherwise leave this blank see our fulls statement at https://www.rtems.org/generative-ai/-->

None

<!--Default settings, if it is a dropdown it will set after submission-->

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1346
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/4-brsunbpfj2xemftfn9cbh5gzh-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260709/e6308b84/attachment-0001.htm>


More information about the bugs mailing list