mirror of https://github.com/RT-Thread/rt-thread
fix dangling pointer in component pthread and dfs_elm (#9976)
* [components/libc/posix][pthreads]fix the risk of dangling pointer * [components][dfs][dfs_elm]:fix risk of dangling pointer, unmount the temp driver then free the temp FATFS in dfs_elm_mkfs.
This commit is contained in:
parent
c16d14e70b
commit
29a06142c5
|
@ -280,8 +280,8 @@ int dfs_elm_mkfs(rt_device_t dev_id, const char *fs_name)
|
|||
/* check flag status, we need clear the temp driver stored in disk[] */
|
||||
if (flag == FSM_STATUS_USE_TEMP_DRIVER)
|
||||
{
|
||||
rt_free(fat);
|
||||
f_mount(RT_NULL, logic_nbr, (BYTE)index);
|
||||
rt_free(fat);
|
||||
disk[index] = RT_NULL;
|
||||
/* close device */
|
||||
rt_device_close(dev_id);
|
||||
|
|
|
@ -319,8 +319,8 @@ int dfs_elm_mkfs(rt_device_t dev_id, const char *fs_name)
|
|||
/* check flag status, we need clear the temp driver stored in disk[] */
|
||||
if (flag == FSM_STATUS_USE_TEMP_DRIVER)
|
||||
{
|
||||
rt_free(fat);
|
||||
f_mount(RT_NULL, logic_nbr, (BYTE)index);
|
||||
rt_free(fat);
|
||||
disk[index] = RT_NULL;
|
||||
/* close device */
|
||||
rt_device_close(dev_id);
|
||||
|
|
|
@ -169,9 +169,6 @@ void _pthread_data_destroy(_pthread_data_t *ptd)
|
|||
/* clean magic */
|
||||
ptd->magic = 0x0;
|
||||
|
||||
/* clear the "ptd->tid->pthread_data" */
|
||||
ptd->tid->pthread_data = RT_NULL;
|
||||
|
||||
/* free ptd */
|
||||
rt_free(ptd);
|
||||
}
|
||||
|
@ -185,6 +182,9 @@ static void _pthread_cleanup(rt_thread_t tid)
|
|||
/* restore tid stack */
|
||||
rt_free(tid->stack_addr);
|
||||
|
||||
/* clear the "ptd->tid->pthread_data" */
|
||||
tid->pthread_data = RT_NULL;
|
||||
|
||||
/* restore tid control block */
|
||||
rt_free(tid);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue