[Linuxptp-devel] [PATCH v2 2/7] clock: Add NULL check for best clock in clock_update_slave()
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Vedang P. <ved...@in...> - 2018-09-26 21:58:08
|
This scenario will only be encountered when the clock transitions to the slave state without knowing who the master is. This will result in a segfault for BMCA with designated master and slave states (to be added in upcoming patches). Signed-off-by: Vedang Patel <ved...@in...> --- clock.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index faf2dea82a5b..0f2e319a19c7 100644 --- a/clock.c +++ b/clock.c @@ -635,7 +635,12 @@ static void clock_update_grandmaster(struct clock *c) static void clock_update_slave(struct clock *c) { struct parentDS *pds = &c->dad.pds; - struct ptp_message *msg = TAILQ_FIRST(&c->best->messages); + struct ptp_message *msg; + + if (!c->best) + return; + + msg = TAILQ_FIRST(&c->best->messages); c->cur.stepsRemoved = 1 + c->best->dataset.stepsRemoved; pds->parentPortIdentity = c->best->dataset.sender; pds->grandmasterIdentity = msg->announce.grandmasterIdentity; -- 2.7.3 |