Skip to content

Commit

Permalink
procfs: access tcb in critical section
Browse files Browse the repository at this point in the history
Signed-off-by: xuxingliang <[email protected]>
  • Loading branch information
XuNeo authored and GUIDINGLI committed Oct 8, 2024
1 parent 8def44b commit 74725b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/procfs/fs_procfsproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 74725b9

Please sign in to comment.