[rtems commit] cpukit/dosfs: Don't leak a FAT FD
Joel Sherrill
joel at rtems.org
Mon Jan 22 15:56:44 UTC 2024
Module: rtems
Branch: master
Commit: 487cdce64dd66dce050c84ab77bb59d7b716dece
Changeset: http://git.rtems.org/rtems/commit/?id=487cdce64dd66dce050c84ab77bb59d7b716dece
Author: Kinsey Moore <kinsey.moore at oarcorp.com>
Date: Tue Jan 16 13:04:14 2024 -0600
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.
---
cpukit/libfs/src/dosfs/msdos_dir.c | 14 +++++++-------
1 file 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;
}
}
More information about the vc
mailing list