Fix a couple more places where the wrong allocator is being used
This commit is contained in:
parent
8f2e9bcfdf
commit
ba7d5acf94
@ -162,14 +162,14 @@ void lib_stream_release(FAR struct task_group_s *group)
|
|||||||
|
|
||||||
if (list->sl_streams[i].fs_bufstart)
|
if (list->sl_streams[i].fs_bufstart)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_ARCH_ADDRENV
|
#ifndef CONFIG_BUILD_KERNEL
|
||||||
/* Release memory from the user heap */
|
/* Release memory from the user heap */
|
||||||
|
|
||||||
sched_ufree(list->sl_streams[i].fs_bufstart);
|
sched_ufree(list->sl_streams[i].fs_bufstart);
|
||||||
#else
|
#else
|
||||||
/* If the exiting group is unprivileged, then it has an address
|
/* If the exiting group is unprivileged, then it has an address
|
||||||
* environment. Don't bother to release the memory in this case...
|
* 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,
|
* will be destroyed anyway. But if this is a privileged group,
|
||||||
* when we still have to release the memory using the kernel
|
* when we still have to release the memory using the kernel
|
||||||
* allocator.
|
* allocator.
|
||||||
@ -177,7 +177,7 @@ void lib_stream_release(FAR struct task_group_s *group)
|
|||||||
|
|
||||||
if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -230,15 +230,39 @@ static inline void group_release(FAR struct task_group_s *group)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \
|
#if CONFIG_NFILE_STREAMS > 0 && defined(CONFIG_MM_KERNEL_HEAP)
|
||||||
defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP)
|
|
||||||
|
|
||||||
/* In a flat, single-heap build. The stream list is part of the
|
/* 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
|
* group structure and, hence will be freed when the group structure
|
||||||
* must be separately de-allocated user the user-space deallocator.
|
* 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);
|
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
|
#endif
|
||||||
|
|
||||||
/* Release the group container itself */
|
/* Release the group container itself */
|
||||||
|
Loading…
Reference in New Issue
Block a user