forked from nuttx/nuttx-update
procfs: access tcb in critical section
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
8def44b65a
commit
74725b9412
1 changed files with 5 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue