Skip to content

Commit 3a73dbb

Browse files
author
Wu Fengguang
committed
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>
1 parent 3155521 commit 3a73dbb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎mm/page-writeback.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,13 +1097,13 @@ static void balance_dirty_pages(struct address_space *mapping,
10971097
pos_ratio = bdi_position_ratio(bdi, dirty_thresh,
10981098
background_thresh, nr_dirty,
10991099
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)) {
11011103
pause = max_pause;
11021104
goto pause;
11031105
}
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;
11071107
if (unlikely(pause <= 0)) {
11081108
trace_balance_dirty_pages(bdi,
11091109
dirty_thresh,

0 commit comments

Comments
 (0)