Skip to content

Commit f3cff25

Browse files
anatolaxboe
authored andcommitted
cfq: explicitly use 64bit divide operation for 64bit arguments
'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]>
1 parent 75afb35 commit f3cff25

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/cfq-iosched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,
18031803

18041804
if (samples) {
18051805
v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum);
1806-
do_div(v, samples);
1806+
v = div64_u64(v, samples);
18071807
}
18081808
__blkg_prfill_u64(sf, pd, v);
18091809
return 0;

0 commit comments

Comments
 (0)