Skip to contentSkip to conversation

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

PATCH In review Vladimir Oltean 3 participants 3 messages Sep 28, 2019 – Oct 1, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 net/sched/sch_cbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_cbs.c +1 -1
index 1bef152c5721..b2905b03a432 100644
@@ -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:
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vladimir Oltean

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")

---

maintainer
#2 lore raw
In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>
Date: Sun, 29 Sep 2019 02:39:48 +0300

Quoted 7 lines

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")

Applied and queued up for -stable.