Skip to content

Commit

Permalink
openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gustavo A. R. Silva authored and David S. Miller committed Jan 31, 2018
1 parent e4823fb commit 5b7789e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/openvswitch/meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
long long int max_bucket_size;

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

band->bucket += delta_ms * band->rate;
if (band->bucket > max_bucket_size)
Expand Down

0 comments on commit 5b7789e

Please sign in to comment.