[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190928233948.15866-1-olteanv@gmail.com>
Date: Sun, 29 Sep 2019 02:39:48 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: davem@...emloft.net, vinicius.gomes@...el.com
Cc: jhs@...atatu.com, xiyou.wangcong@...il.com, netdev@...r.kernel.org,
Vladimir Oltean <olteanv@...il.com>
Subject: [PATCH net] 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@...il.com>
---
net/sched/sch_cbs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
index 1bef152c5721..b2905b03a432 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:
--
2.17.1
Powered by blists - more mailing lists