1
0
Fork 0
forked from nuttx/nuttx-update

procfs: access tcb in critical section

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-08-22 17:03:32 +08:00 committed by GUIDINGLI
parent 8def44b65a
commit 74725b9412

View file

@ -1571,6 +1571,7 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
{
FAR struct proc_file_s *procfile;
FAR struct tcb_s *tcb;
irqstate_t flags;
ssize_t ret;
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
@ -1582,9 +1583,11 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
/* Verify that the thread is still valid */
flags = enter_critical_section();
tcb = nxsched_get_tcb(procfile->pid);
if (tcb == NULL)
{
leave_critical_section(flags);
ferr("ERROR: PID %d is not valid\n", procfile->pid);
return -ENODEV;
}
@ -1644,6 +1647,8 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
break;
}
leave_critical_section(flags);
/* Update the file offset */
if (ret > 0)