RTEMS | cpukit/libio: Fix race condition in iop free (!1048)

Allan Hessenflow (@allanhessenflow) gitlab at rtems.org
Fri Feb 6 18:51:06 UTC 2026




Allan Hessenflow commented on a discussion on cpukit/libcsupport/src/libio.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1048#note_142056

 >  void rtems_libio_free_iop( rtems_libio_t *iop )
 >  {
 >    size_t zero;
 > +  unsigned int flags;
 >  
 > +  flags = rtems_libio_iop_flags_set( iop, LIBIO_FLAGS_FREE );
 > +  if ( (flags & LIBIO_FLAGS_FREE ) == 0 ) {
 >      rtems_libio_lock();

I might be missing something but I don't believe it is.  That is an atomic test/set so the code inside that if() can only execute once on a non-free fd.  The only code that could set the free flag cannot do so on that fd because it is not in the free list until the code inside the lock adds it.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1048#note_142056
You're receiving this email because of your account on gitlab.rtems.org.


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


More information about the bugs mailing list