* [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate
@ 2019-09-28 23:39 Vladimir Oltean
2019-09-30 16:37 ` Vinicius Costa Gomes
2019-10-01 16:52 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2019-09-28 23:39 UTC (permalink / raw)
To: davem, vinicius.gomes; +Cc: jhs, xiyou.wangcong, netdev, 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")
Signed-off-by: Vladimir Oltean <olteanv@gmail.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate
2019-09-28 23:39 [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate Vladimir Oltean
@ 2019-09-30 16:37 ` Vinicius Costa Gomes
2019-10-01 16:52 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Vinicius Costa Gomes @ 2019-09-30 16:37 UTC (permalink / raw)
To: Vladimir Oltean, davem; +Cc: jhs, xiyou.wangcong, netdev, Vladimir Oltean
Vladimir Oltean <olteanv@gmail.com> writes:
> 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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate
2019-09-28 23:39 [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate Vladimir Oltean
2019-09-30 16:37 ` Vinicius Costa Gomes
@ 2019-10-01 16:52 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-10-01 16:52 UTC (permalink / raw)
To: olteanv; +Cc: vinicius.gomes, jhs, xiyou.wangcong, netdev
From: Vladimir Oltean <olteanv@gmail.com>
Date: Sun, 29 Sep 2019 02:39:48 +0300
> 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>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-01 16:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-28 23:39 [PATCH net] net: sched: cbs: Avoid division by zero when calculating the port rate Vladimir Oltean
2019-09-30 16:37 ` Vinicius Costa Gomes
2019-10-01 16:52 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).