forked from Minki/linux
net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte
The speed divisor is used in a context expecting an s64, but it is
evaluated using 32-bit arithmetic.
To avoid that happening, instead of multiplying by 1,000,000 in the
first place, simplify the fraction and do a standard 32 bit division
instead.
Fixes: f04b514c0c
("taprio: Set default link speed to 10 Mbps in taprio_set_picos_per_byte")
Reported-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
68501df92d
commit
68ce6688a5
@ -1048,8 +1048,7 @@ static void taprio_set_picos_per_byte(struct net_device *dev,
|
||||
speed = ecmd.base.speed;
|
||||
|
||||
skip:
|
||||
picos_per_byte = div64_s64(NSEC_PER_SEC * 1000LL * 8,
|
||||
speed * 1000 * 1000);
|
||||
picos_per_byte = (USEC_PER_SEC * 8) / speed;
|
||||
|
||||
atomic64_set(&q->picos_per_byte, picos_per_byte);
|
||||
netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user