diff options
author | Alberto Garcia <berto@igalia.com> | 2017-09-13 11:28:17 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-09-26 14:46:23 +0200 |
commit | b5806108d20fc32b4692e721d8bd6376f4ca4a69 (patch) | |
tree | 85e7f935c7dfe158516c34b04bfc57923d146275 | |
parent | 93e53fb6952c85ef54b209c92358963fb66d0fa2 (diff) | |
download | qemu-b5806108d20fc32b4692e721d8bd6376f4ca4a69.zip qemu-b5806108d20fc32b4692e721d8bd6376f4ca4a69.tar.gz qemu-b5806108d20fc32b4692e721d8bd6376f4ca4a69.tar.bz2 |
throttle: Assert that bkt->max is valid in throttle_compute_wait()
If bkt->max == 0 and bkt->burst_length > 1 then we could have a
division by 0 in throttle_do_compute_wait(). That configuration is
however not permitted and is already detected by throttle_is_valid(),
but let's assert it in throttle_compute_wait() to make it explicit.
Found by Coverity (CID: 1381016).
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | util/throttle.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/util/throttle.c b/util/throttle.c index 06bf916..b38e742 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -124,6 +124,7 @@ int64_t throttle_compute_wait(LeakyBucket *bkt) /* If the main bucket is not full yet we still have to check the * burst bucket in order to enforce the burst limit */ if (bkt->burst_length > 1) { + assert(bkt->max > 0); /* see throttle_is_valid() */ extra = bkt->burst_level - burst_bucket_size; if (extra > 0) { return throttle_do_compute_wait(bkt->max, extra); |