diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 94e6c587539d..efdc2117f50e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4917,6 +4917,7 @@ static inline bool is_sched_lib_based_app(pid_t pid) char path_buf[LIB_PATH_LENGTH]; bool found = false; struct task_struct *p; + struct mm_struct *mm; if (strnlen(sched_lib_name, LIB_PATH_LENGTH) == 0) return false; @@ -4933,11 +4934,12 @@ static inline bool is_sched_lib_based_app(pid_t pid) get_task_struct(p); rcu_read_unlock(); - if (!p->mm) + mm = get_task_mm(p); + if (!mm) goto put_task_struct; - down_read(&p->mm->mmap_sem); - for (vma = p->mm->mmap; vma ; vma = vma->vm_next) { + down_read(&mm->mmap_sem); + for (vma = mm->mmap; vma ; vma = vma->vm_next) { if (vma->vm_file && vma->vm_flags & VM_EXEC) { name = d_path(&vma->vm_file->f_path, path_buf, LIB_PATH_LENGTH); @@ -4953,7 +4955,8 @@ static inline bool is_sched_lib_based_app(pid_t pid) } release_sem: - up_read(&p->mm->mmap_sem); + up_read(&mm->mmap_sem); + mmput(mm); put_task_struct: put_task_struct(p); return found;