]> git.baikalelectronics.ru Git - kernel.git/commit
blk-iocost: fix divide-by-zero in transfer_surpluses()
authorTejun Heo <tj@kernel.org>
Fri, 11 Sep 2020 22:40:49 +0000 (18:40 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Sep 2020 22:41:47 +0000 (16:41 -0600)
commit897d24f5d0751bb1991f752ea484c48721bd51f1
tree39ebaa9dc4a2a062fe38ea3aebfdce8d1c642cc9
parentf461bc01cb47c7adb131abab932557a582221dd0
blk-iocost: fix divide-by-zero in transfer_surpluses()

Conceptually, root_iocg->hweight_donating must be less than WEIGHT_ONE but
all hweight calculations round up and thus it may end up >= WEIGHT_ONE
triggering divide-by-zero and other issues. Bound the value to avoid
surprises.

Fixes: 9c274fbf43b5 ("blk-iocost: implement Andy's method for donation weight updates")
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c