risc-v/esp32-c3: fix pid initiatialization on esp32c3_rt_timer.c

pid variable was initialized to -EINVAL to prevent rt_timer_deinit
from delete an invalid kthread. But priv->pid was being overwritten in the
rt_timer_init, so in case of failure to create a kthread, it would
call rt_timer_deinit with a non expected initialization value.
This commit is contained in:
Sara Souza 2021-09-23 11:27:06 -03:00 committed by Xiang Xiao
parent d0e7d7b77f
commit 9c2c5d3919
1 changed files with 5 additions and 3 deletions

View File

@ -718,21 +718,23 @@ int esp32c3_rt_timer_init(void)
nxsem_init(&priv->toutsem, 0, 0);
priv->pid = kthread_create(RT_TIMER_TASK_NAME,
pid = kthread_create(RT_TIMER_TASK_NAME,
RT_TIMER_TASK_PRIORITY,
RT_TIMER_TASK_STACK_SIZE,
rt_timer_thread,
NULL);
if (priv->pid < 0)
if (pid < 0)
{
tmrerr("ERROR: Failed to create RT timer task error=%d\n", pid);
esp32c3_tim_deinit(priv->timer);
return priv->pid;
return pid;
}
list_initialize(&priv->runlist);
list_initialize(&priv->toutlist);
priv->pid = pid;
flags = enter_critical_section();
/* ESP32-C3 hardware timer configuration: