Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3cff25f authored by Anatol Pomozov's avatar Anatol Pomozov Committed by Jens Axboe
Browse files

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: default avatarAnatol Pomozov <anatol.pomozov@gmail.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 75afb352
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;