]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cfq: explicitly use 64bit divide operation for 64bit arguments
authorAnatol Pomozov <anatol.pomozov@gmail.com>
Sun, 22 Sep 2013 18:43:47 +0000 (12:43 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 22 Sep 2013 18:43:47 +0000 (12:43 -0600)
'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 <anatol.pomozov@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/cfq-iosched.c

index f0468e252ee4217ce0f40fcbf06e29bc6b559b2d..51e06ea06a2e9a9ce99d7a3a880b40b7445119b3 100644 (file)
@@ -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;