Commit 83c8c3cf authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

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: e0a7683d ("net/sched: cbs: fix port_rate miscalculation")
Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
Acked-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a9251a3
...@@ -306,7 +306,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q) ...@@ -306,7 +306,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q)
if (err < 0) if (err < 0)
goto skip; goto skip;
if (ecmd.base.speed != SPEED_UNKNOWN) if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN)
speed = ecmd.base.speed; speed = ecmd.base.speed;
skip: skip:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment