summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-11 15:56:04 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-11 15:56:04 -0600
commitc0e2f523bda5849e2a176a745aba23e99940f1a6 (patch)
tree78c1d372cd8a442997953465d0d4de13d4bc16df
parent11bc92f16c7bcee581e2321c36680e1a99dc2e2b (diff)
downloadnuttx-c0e2f523bda5849e2a176a745aba23e99940f1a6.tar.gz
nuttx-c0e2f523bda5849e2a176a745aba23e99940f1a6.tar.bz2
nuttx-c0e2f523bda5849e2a176a745aba23e99940f1a6.zip
Fix a couple more places where the wrong allocator is being used
-rw-r--r--nuttx/libc/misc/lib_stream.c6
-rw-r--r--nuttx/sched/group/group_leave.c34
2 files changed, 32 insertions, 8 deletions
diff --git a/nuttx/libc/misc/lib_stream.c b/nuttx/libc/misc/lib_stream.c
index f15215723..2ad3cd740 100644
--- a/nuttx/libc/misc/lib_stream.c
+++ b/nuttx/libc/misc/lib_stream.c
@@ -162,14 +162,14 @@ void lib_stream_release(FAR struct task_group_s *group)
if (list->sl_streams[i].fs_bufstart)
{
-#ifndef CONFIG_ARCH_ADDRENV
+#ifndef CONFIG_BUILD_KERNEL
/* Release memory from the user heap */
sched_ufree(list->sl_streams[i].fs_bufstart);
#else
/* If the exiting group is unprivileged, then it has an address
* environment. Don't bother to release the memory in this case...
- * There is no point sense the memory lies in the user heap which
+ * There is no point since the memory lies in the user heap which
* will be destroyed anyway. But if this is a privileged group,
* when we still have to release the memory using the kernel
* allocator.
@@ -177,7 +177,7 @@ void lib_stream_release(FAR struct task_group_s *group)
if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
{
- sched_ufree(list->sl_streams[i].fs_bufstart);
+ sched_kfree(list->sl_streams[i].fs_bufstart);
}
#endif
}
diff --git a/nuttx/sched/group/group_leave.c b/nuttx/sched/group/group_leave.c
index bcf9e1dae..6b44ba68a 100644
--- a/nuttx/sched/group/group_leave.c
+++ b/nuttx/sched/group/group_leave.c
@@ -230,15 +230,39 @@ static inline void group_release(FAR struct task_group_s *group)
}
#endif
-#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \
- defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP)
-
+#if CONFIG_NFILE_STREAMS > 0 && defined(CONFIG_MM_KERNEL_HEAP)
/* In a flat, single-heap build. The stream list is part of the
- * group structure. But in a kernel build with a kernel allocator, it
- * must be separately de-allocated user the user-space deallocator.
+ * group structure and, hence will be freed when the group structure
+ * is freed. Otherwise, it is separately allocated an must be
+ * freed here.
+ */
+
+# if defined(CONFIG_BUILD_PROTECTED)
+ /* In the protected build, the task's stream list is always allocated
+ * and freed from the single, global user allocator.
*/
sched_ufree(group->tg_streamlist);
+
+# elif defined(CONFIG_BUILD_KERNEL)
+ /* In the kernel build, the unprivileged process' stream list will be
+ * allocated from with its per-process, private user heap. But in that
+ * case, there is no reason to do anything here: That allocation resides
+ * in the user heap which which be completely freed when we destroy the
+ * process' address environment.
+ */
+
+ if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
+ {
+ /* But kernel threads are different in this build configuration: Their
+ * stream lists were allocated from the common, global kernel heap and
+ * must explicitly freed here.
+ */
+
+ sched_kfree(group->tg_streamlist);
+ }
+
+# endif
#endif
/* Release the group container itself */