diff --git a/port.c b/port.c
index eaf77e6..4debbe1 100644
--- a/port.c
+++ b/port.c
@@ -2767,12 +2767,35 @@ enum fsm_event port_event(struct port *p, int fd_index)
return p->event(p, fd_index);
}
+static int port_check_tmo_valid(struct port *p, int fd_index)
+{
+ struct itimerspec tms;
+
+ if (fd_index < FD_FIRST_TIMER || fd_index >= (FD_FIRST_TIMER + N_TIMER_FDS))
+ return 1;
+
+ /* return valid if we somehow end up quering non-timer fd */
+ if (timerfd_gettime(p->fda.fd[fd_index], &tms) < 0)
+ return 1;
+ /* timer was not updated, expire valid */
+ if (tms.it_value.tv_sec == 0 && tms.it_value.tv_nsec == 0)
+ return 1;
+
+ /* timer was updated by new message read from the sockets */
+ pr_notice("%s: Timer %d expired, but was already updated, ignore",
+ p->log_name, fd_index);
+ return 0;
+}
+
static enum fsm_event bc_event(struct port *p, int fd_index)
{
enum fsm_event event = EV_NONE;
struct ptp_message *msg;
int cnt, fd = p->fda.fd[fd_index], err;
+ if (!port_check_tmo_valid(p, fd_index))
+ return event;
+
switch (fd_index) {
case FD_ANNOUNCE_TIMER:
case FD_SYNC_RX_TIMER: