Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sched: cbs: Avoid division by zero when calculating the port rate

As explained in the "net: sched: taprio: Avoid division by zero on
invalid link speed" commit, it is legal for the ethtool API to return
zero as a link speed. So guard against it to ensure we don't perform a
division by zero in kernel.

Fixes: e0a7683d30e9 ("net/sched: cbs: fix port_rate miscalculation")
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>

authored by

Vladimir Oltean and committed by
David S. Miller
83c8c3cf 9a9251a3

+1 -1
+1 -1
net/sched/sch_cbs.c
··· 306 306 if (err < 0) 307 307 goto skip; 308 308 309 - if (ecmd.base.speed != SPEED_UNKNOWN) 309 + if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN) 310 310 speed = ecmd.base.speed; 311 311 312 312 skip: