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 <vedang.pa...@intel.com>
---
 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



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to