sched: add sanity check in partition_sched_domains()
PATCH 1/1 sched: add sanity check in partition_sched_domains()
It's wrong to make dattr_new = NULL if doms_new == NULL, it introduces memory leak if dattr_new != NULL. Fortunately dattr_new is always NULL in this case. So remove the code and add a sanity check.
--- kernel/sched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
@@ -7787,7 +7787,7 @@ match1: ndoms_cur =0 ; doms_new = &fallback_doms;cpus_andnot (doms_new[0 ], cpu_online_map, cpu_isolated_map); - dattr_new =NULL ; +BUG_ON (dattr_new); }/* Build new domains */
Signature · 1 line
1.5.4.rc3
Ingo Molnar
AppliedQuoted 8 lines · Li Zefan
It's wrong to make
dattr_new= NULL ifdoms_new== NULL, it introduces memory leak ifdattr_new!= NULL. Fortunatelydattr_newis always NULL in this case. So remove the code and add a sanity check.Signed-off-by Li Zefan <[email protected]>--- kernel/sched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
applied to tip/sched/core, thanks!
a small detail, i changed this:
kernel/sched.c match1: · line 7790
Quoted 1 line
kernel/sched.c +1
-0+BUG_ON (dattr_new);
to WARN_ON_ONCE().
If there's a rare setup-time memory leak we dont want to crash the box via a BUG_ON(), as that only results in unhappy users. We want a WARN_ON_ONCE() so that we get nice bugreports and kerneloops.org coverage as well instead.
We use BUG_ON() in new code only in the rarest of circumstances: if we absolutely want to bring down the box right there - because there's a serious risk of data corruption, security breach, etc.
Ingo
Quoted 6 lines
a small detail, i changed this:
kernel/sched.c match1: · line 7790
Quoted 1 line
kernel/sched.c +1
-0+BUG_ON (dattr_new);to
WARN_ON_ONCE().
Quoted 9 lines
If there's a rare setup-time memory leak we dont want to crash the box via a
BUG_ON(), as that only results in unhappy users. We want aWARN_ON_ONCE()so that we get nice bugreports and kerneloops.org coverage as well instead.We use
BUG_ON()in new code only in the rarest of circumstances: if we absolutely want to bring down the box right there - because there's a serious risk of data corruption, security breach, etc.
I see the point, thx for the explanation. :)