Commit 3a73dbbc9bb3fc8594cd67af4db6c563175dfddb
1 parent
31555213f0
Exists in
master
and in
6 other branches
writeback: fix uninitialized task_ratelimit
In balance_dirty_pages() task_ratelimit may be not initialized (initialization skiped by goto pause), and then used when calling tracing hook. Fix it by moving the task_ratelimit assignment before goto pause. Reported-by: Witold Baryluk <baryluk@smp.if.uj.edu.pl> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff
mm/page-writeback.c
... | ... | @@ -1097,13 +1097,13 @@ |
1097 | 1097 | pos_ratio = bdi_position_ratio(bdi, dirty_thresh, |
1098 | 1098 | background_thresh, nr_dirty, |
1099 | 1099 | bdi_thresh, bdi_dirty); |
1100 | - if (unlikely(pos_ratio == 0)) { | |
1100 | + task_ratelimit = ((u64)dirty_ratelimit * pos_ratio) >> | |
1101 | + RATELIMIT_CALC_SHIFT; | |
1102 | + if (unlikely(task_ratelimit == 0)) { | |
1101 | 1103 | pause = max_pause; |
1102 | 1104 | goto pause; |
1103 | 1105 | } |
1104 | - task_ratelimit = (u64)dirty_ratelimit * | |
1105 | - pos_ratio >> RATELIMIT_CALC_SHIFT; | |
1106 | - pause = (HZ * pages_dirtied) / (task_ratelimit | 1); | |
1106 | + pause = HZ * pages_dirtied / task_ratelimit; | |
1107 | 1107 | if (unlikely(pause <= 0)) { |
1108 | 1108 | trace_balance_dirty_pages(bdi, |
1109 | 1109 | dirty_thresh, |