Skip to content

Commit

Permalink
Merge tag 'sched_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/tip

Pull scheduler fix from Borislav Petkov:
 "Fix a NULL-ptr dereference when recalculating a sched entity's weight"

* tag 'sched_urgent_for_v5.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/fair: Fix fault in reweight_entity
  • Loading branch information
Linus Torvalds committed Feb 13, 2022
2 parents f5e0265 + 13765de commit 6f35736
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,9 @@ int tg_nop(struct task_group *tg, void *data)
}
#endif

static void set_load_weight(struct task_struct *p, bool update_load)
static void set_load_weight(struct task_struct *p)
{
bool update_load = !(READ_ONCE(p->__state) & TASK_NEW);
int prio = p->static_prio - MAX_RT_PRIO;
struct load_weight *load = &p->se.load;

Expand Down Expand Up @@ -4406,7 +4407,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
p->static_prio = NICE_TO_PRIO(0);

p->prio = p->normal_prio = p->static_prio;
set_load_weight(p, false);
set_load_weight(p);

/*
* We don't need the reset flag anymore after the fork. It has
Expand Down Expand Up @@ -6921,7 +6922,7 @@ void set_user_nice(struct task_struct *p, long nice)
put_prev_task(rq, p);

p->static_prio = NICE_TO_PRIO(nice);
set_load_weight(p, true);
set_load_weight(p);
old_prio = p->prio;
p->prio = effective_prio(p);

Expand Down Expand Up @@ -7212,7 +7213,7 @@ static void __setscheduler_params(struct task_struct *p,
*/
p->rt_priority = attr->sched_priority;
p->normal_prio = normal_prio(p);
set_load_weight(p, true);
set_load_weight(p);
}

/*
Expand Down Expand Up @@ -9445,7 +9446,7 @@ void __init sched_init(void)
#endif
}

set_load_weight(&init_task, false);
set_load_weight(&init_task);

/*
* The boot idle thread does lazy MMU switching as well:
Expand Down

0 comments on commit 6f35736

Please sign in to comment.