[PATCH 4/7] Fix qdisc_watchdog_schedule_range_ns range check

From: Erez Geva
Date: Thu Oct 01 2020 - 17:01:32 EST


- As all parameters are unsigned.

- If 'expires' is bigger than 'last_expires' then the left expression
overflows.

- It is better to use addition and check both ends of the range.

Signed-off-by: Erez Geva <erez.geva.ext@xxxxxxxxxxx>
---
net/sched/sch_api.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 2a76a2f5ed88..ebf59ca1faab 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -632,7 +632,8 @@ void qdisc_watchdog_schedule_range_ns(struct qdisc_watchdog *wd, u64 expires,
/* If timer is already set in [expires, expires + delta_ns],
* do not reprogram it.
*/
- if (wd->last_expires - expires <= delta_ns)
+ if (wd->last_expires >= expires &&
+ wd->last_expires <= expires + delta_ns)
return;
}

--
2.20.1