diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2024-01-16 13:04:14 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2024-01-22 09:56:40 -0600 |
commit | 487cdce64dd66dce050c84ab77bb59d7b716dece (patch) | |
tree | a801d72860060c50137513f6808d8c898a0d4a81 | |
parent | fstests/tftpfs: Fix build dependency (diff) | |
download | rtems-487cdce64dd66dce050c84ab77bb59d7b716dece.tar.bz2 |
cpukit/dosfs: Don't leak a FAT FD
The tmp_fat_fd variable is unconditionally opened in the branch where it
is used within the loop and so must be closed or else risk a resource
leak.
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_dir.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c b/cpukit/libfs/src/dosfs/msdos_dir.c index 4ae2c32415..d9585635d9 100644 --- a/cpukit/libfs/src/dosfs/msdos_dir.c +++ b/cpukit/libfs/src/dosfs/msdos_dir.c @@ -339,14 +339,14 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) iop->offset = iop->offset + sizeof(struct dirent); cmpltd += (sizeof(struct dirent)); count -= (sizeof(struct dirent)); + } - /* inode number extracted, close fat-file */ - rc = fat_file_close(&fs_info->fat, tmp_fat_fd); - if (rc != RC_OK) - { - msdos_fs_unlock(fs_info); - return rc; - } + /* inode number extracted, close fat-file */ + rc = fat_file_close(&fs_info->fat, tmp_fat_fd); + if (rc != RC_OK) + { + msdos_fs_unlock(fs_info); + return rc; } } |