summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/dosfs.h
diff options
context:
space:
mode:
authorChristian Mauderer <christian.mauderer@embedded-brains.de>2020-08-03 14:18:33 +0200
committerChristian Mauderer <christian.mauderer@embedded-brains.de>2020-08-04 08:26:58 +0200
commit4a2ac5ef8d7e8bac4c63b26420d0df08ce82aa09 (patch)
treead01f9a18d8e18aeadd47b3ffbab5fcc82ade46a /cpukit/include/rtems/dosfs.h
parentrtems: Add rtems_interrupt_server_create() (diff)
downloadrtems-4a2ac5ef8d7e8bac4c63b26420d0df08ce82aa09.tar.bz2
dosfs: Fix memory leak on failed mounts.
Currently if mount fails, a converter isn't destroyed. We have to take care of two cases: 1. The user doesn't provide a converter. In this case mounting a dosfs creates a default converter. This patch makes sure that the converter is destroyed again if mount failes for this case. 2. The user provides a converter. In this case it's not sure that the dosfs specific routines are reached because mount can fail before that. Therefore the user has to destroy the converter himself again. This patch adds a documentation for that and implements it in the media server. Closes #4041.
Diffstat (limited to 'cpukit/include/rtems/dosfs.h')
-rw-r--r--cpukit/include/rtems/dosfs.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/cpukit/include/rtems/dosfs.h b/cpukit/include/rtems/dosfs.h
index 7691ed7e43..70347f0c05 100644
--- a/cpukit/include/rtems/dosfs.h
+++ b/cpukit/include/rtems/dosfs.h
@@ -214,6 +214,9 @@ typedef struct {
/**
* @brief Converter implementation for new file system instance.
*
+ * Note: If you pass a converter to mount, you have to destroy it yourself if
+ * mount failed. In a good case it is destroyed at unmount.
+ *
* Before converters have been added to the RTEMS implementation of the FAT
* file system, the implementation was:
* - Short names were saved in code page format (as is still the case).
@@ -270,6 +273,10 @@ typedef struct {
* RTEMS_FILESYSTEM_READ_WRITE,
* &mount_opts
* );
+ *
+ * if (rv != 0) {
+ * (*mount_opts.converter->handler->destroy)(mount_opts.converter);
+ * }
* } else {
* rv = -1;
* errno = ENOMEM;