summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/sup_fs_deviceio.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-03-10 17:07:19 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-03-13 09:57:04 +0100
commitc2287ba2cff59a50848151833404bce0e3cf0a70 (patch)
tree24fbd290baf4722b2dd56df731f44b41b6765c45 /cpukit/libcsupport/src/sup_fs_deviceio.c
parentmrm332-testsuite.tcfg: Add dl01 (diff)
downloadrtems-c2287ba2cff59a50848151833404bce0e3cf0a70.tar.bz2
libio: Robust file descriptor reference counting
There was a race conditon in the reference counting of file descriptors during a close() operation. After the call to the close handler, the rtems_libio_free() function cleared the flags to zero. However, at this point in time there may still exist some holders of the file descriptor. With RTEMS_DEBUG enabled this could lead to failed assertions in rtems_libio_iop_drop(). Change the code to use only atomic read-modify-write operations on the rtems_libio_iop::flags.
Diffstat (limited to 'cpukit/libcsupport/src/sup_fs_deviceio.c')
-rw-r--r--cpukit/libcsupport/src/sup_fs_deviceio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/cpukit/libcsupport/src/sup_fs_deviceio.c b/cpukit/libcsupport/src/sup_fs_deviceio.c
index 294e14a260..4a7e0dd13c 100644
--- a/cpukit/libcsupport/src/sup_fs_deviceio.c
+++ b/cpukit/libcsupport/src/sup_fs_deviceio.c
@@ -34,7 +34,7 @@ int rtems_deviceio_open(
rtems_libio_open_close_args_t args;
args.iop = iop;
- args.flags = iop->flags;
+ args.flags = rtems_libio_iop_flags( iop );
args.mode = mode;
status = rtems_io_open( major, minor, &args );
@@ -75,7 +75,7 @@ ssize_t rtems_deviceio_read(
args.offset = iop->offset;
args.buffer = buf;
args.count = nbyte;
- args.flags = iop->flags;
+ args.flags = rtems_libio_iop_flags( iop );
args.bytes_moved = 0;
status = rtems_io_read( major, minor, &args );
@@ -103,7 +103,7 @@ ssize_t rtems_deviceio_write(
args.offset = iop->offset;
args.buffer = RTEMS_DECONST( void *, buf );
args.count = nbyte;
- args.flags = iop->flags;
+ args.flags = rtems_libio_iop_flags( iop );
args.bytes_moved = 0;
status = rtems_io_write( major, minor, &args );