Skip to content

Commit 5b7789e

Browse files
GustavoARSilvadavem330
authored andcommitted
openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
Add suffix LL to constant 1000 in order to give the compiler complete information about the proper arithmetic to use. Notice that this constant is used in a context that expects an expression of type long long int (64 bits, signed). The expression (band->burst_size + band->rate) * 1000 is currently being evaluated using 32-bit arithmetic. Addresses-Coverity-ID: 1461563 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e4823fb commit 5b7789e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎net/openvswitch/meter.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
488488
long long int max_bucket_size;
489489

490490
band = &meter->bands[i];
491-
max_bucket_size = (band->burst_size + band->rate) * 1000;
491+
max_bucket_size = (band->burst_size + band->rate) * 1000LL;
492492

493493
band->bucket += delta_ms * band->rate;
494494
if (band->bucket > max_bucket_size)

0 commit comments

Comments
 (0)