Skip to content

Commit

Permalink
cfq: explicitly use 64bit divide operation for 64bit arguments
Browse files Browse the repository at this point in the history
'samples' is 64bit operant, but do_div() second parameter is 32.
do_div silently truncates high 32 bits and calculated result
is invalid.

In case if low 32bit of 'samples' are zeros then do_div() produces
kernel crash.

Signed-off-by: Anatol Pomozov <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
anatol authored and axboe committed Sep 22, 2013
1 parent 75afb35 commit f3cff25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,

if (samples) {
v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum);
do_div(v, samples);
v = div64_u64(v, samples);
}
__blkg_prfill_u64(sf, pd, v);
return 0;
Expand Down

0 comments on commit f3cff25

Please sign in to comment.