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:
parent
d0e7d7b77f
commit
9c2c5d3919
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user