summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Oltean <olteanv@gmail.com>2019-09-29 02:39:48 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-07 18:58:27 +0200
commit411184eda7d0a07ddf2e762f36a7dcbf29d00bfb (patch)
treec1ffb0d46dd68fa742dce70bf34abe7cba1a31d6
parent90053e8de295f280dac583f57aef0295728c0bd9 (diff)
downloadlinux-stable-411184eda7d0a07ddf2e762f36a7dcbf29d00bfb.tar.gz
linux-stable-411184eda7d0a07ddf2e762f36a7dcbf29d00bfb.tar.bz2
linux-stable-411184eda7d0a07ddf2e762f36a7dcbf29d00bfb.zip
net: sched: cbs: Avoid division by zero when calculating the port rate
[ Upstream commit 83c8c3cf45163f0c823db37be6ab04dfcf8ac751 ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/sched/sch_cbs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
index 4a403d35438f..284ab2dcf47f 100644
--- a/net/sched/sch_cbs.c
+++ b/net/sched/sch_cbs.c
@@ -306,7 +306,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q)
if (err < 0)
goto skip;
- if (ecmd.base.speed != SPEED_UNKNOWN)
+ if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN)
speed = ecmd.base.speed;
skip: