diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-03-16 11:59:23 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-03-21 16:15:21 +0100 |
commit | 89164c67bcd3572c31a4d8b256a96271dec49526 (patch) | |
tree | 34b4932785e9b13aea017dd49fc2c173f1f54c7a /cpukit | |
parent | dosfs: Rename fat_entries to lfn_entries (diff) | |
download | rtems-89164c67bcd3572c31a4d8b256a96271dec49526.tar.bz2 |
dosfs: Fix race condition msdos_dir_read()
Obtain file system instance lock before member access.
Close #2937.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_dir.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c b/cpukit/libfs/src/dosfs/msdos_dir.c index 577dc4d4db..40f9f0f4c0 100644 --- a/cpukit/libfs/src/dosfs/msdos_dir.c +++ b/cpukit/libfs/src/dosfs/msdos_dir.c @@ -88,6 +88,11 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) size_t string_size = sizeof(tmp_dirent.d_name); bool is_first_entry; + sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT, + MSDOS_VOLUME_SEMAPHORE_TIMEOUT); + if (sc != RTEMS_SUCCESSFUL) + rtems_set_errno_and_return_minus_one(EIO); + /* * cast start and count - protect against using sizes that are not exact * multiples of the -dirent- size. These could result in unexpected @@ -107,11 +112,6 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) fat_fd->fat_file_size : fs_info->fat.vol.bpc; - sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT, - MSDOS_VOLUME_SEMAPHORE_TIMEOUT); - if (sc != RTEMS_SUCCESSFUL) - rtems_set_errno_and_return_minus_one(EIO); - while (count > 0 && cmpltd >= 0) { /* |