From 16b6d365e949b28718cb395b6e8981359feb8e0f Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Tue, 18 Oct 2022 19:33:34 +0800 Subject: [PATCH] fs/procfs: check task status before get group info When ps cmd is invoked during the task exit process, the group information of the task may be deleted. So need check the task flag before get the task group information. --- fs/procfs/fs_procfsproc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index f628753fa2..f5919a2580 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -493,7 +493,6 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile, FAR struct tcb_s *tcb, FAR char *buffer, size_t buflen, off_t offset) { - FAR struct task_group_s *group; FAR const char *policy; FAR const char *name; size_t remaining; @@ -543,12 +542,9 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile, return totalsize; } - group = tcb->group; - DEBUGASSERT(group != NULL); - linesize = procfs_snprintf(procfile->line, STATUS_LINELEN, - "%-12s%d\n", - "Group:", group->tg_pid); + "%-12s%d\n", "Group:", + tcb->group ? tcb->group->tg_pid : -1); copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);