Guard against divide by zero.
If a buggy driver or hardware delivers bogus time stamps, then we might crash with a divide by zero exception. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
35170cf6e4
commit
8f5bd0edda
4
clock.c
4
clock.c
|
@ -209,6 +209,10 @@ static enum servo_state clock_no_adjust(struct clock *c)
|
|||
if (f->count < f->max_count) {
|
||||
return state;
|
||||
}
|
||||
if (tmv_eq(c->t2, f->ingress1)) {
|
||||
pr_warning("bad timestamps in rate ratio calculation");
|
||||
return state;
|
||||
}
|
||||
/*
|
||||
* origin2 = c->t1 (+c->path_delay) + c->c1 + c->c2;
|
||||
*/
|
||||
|
|
4
port.c
4
port.c
|
@ -407,6 +407,10 @@ static void port_nrate_calculate(struct port *p, tmv_t t3, tmv_t t4, tmv_t c)
|
|||
return;
|
||||
}
|
||||
origin2 = tmv_add(t3, c);
|
||||
if (tmv_eq(t4, n->ingress1)) {
|
||||
pr_warning("bad timestamps in nrate calculation");
|
||||
return;
|
||||
}
|
||||
n->ratio =
|
||||
tmv_dbl(tmv_sub(origin2, n->origin1)) /
|
||||
tmv_dbl(tmv_sub(t4, n->ingress1));
|
||||
|
|
Loading…
Reference in New Issue