On 09/13/2017 03:28 AM, Alberto Garcia wrote: > 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 <be...@igalia.com> > --- > util/throttle.c | 1 + > 1 file changed, 1 insertion(+)
Reviewed-by: Eric Blake <ebl...@redhat.com> > > diff --git a/util/throttle.c b/util/throttle.c > index 06bf916adc..b38e742da5 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); > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature