From: Vladimir Oltean Date: Sat, 28 Sep 2019 23:39:48 +0000 (+0300) Subject: net: sched: cbs: Avoid division by zero when calculating the port rate X-Git-Tag: v5.4-rc2~7^2~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83c8c3cf45163f0c823db37be6ab04dfcf8ac751;p=platform%2Fkernel%2Flinux-rpi.git 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 Acked-by: Vinicius Costa Gomes Signed-off-by: David S. Miller --- 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: