summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-16 11:59:23 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-21 16:15:21 +0100
commit89164c67bcd3572c31a4d8b256a96271dec49526 (patch)
tree34b4932785e9b13aea017dd49fc2c173f1f54c7a /cpukit
parent4c4869f48383986a7f36c18a0f3b52f7c39e6087 (diff)
downloadrtems-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.c10
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)
{
/*