From 852d587fd3ad305a05e2b0bfcd6aaf29e6d5247f Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 28 Aug 2012 07:51:04 +0200 Subject: [PATCH] Drop the reference to best when freeing the foreign masters. This fixes the following issue reported by valgrind, which occurs after a port disable/initialize subsequent to having entered slave mode. ==10651== Invalid read of size 4 ==10651== at 0x804E6E2: fc_clear (port.c:175) ==10651== by 0x805132F: port_event (port.c:1352) ==10651== by 0x804B383: clock_poll (clock.c:597) ==10651== by 0x80498AE: main (ptp4l.c:278) ==10651== Address 0x41cba60 is 16 bytes inside a block of size 60 free'd ==10651== at 0x4023B6A: free (vg_replace_malloc.c:366) ==10651== by 0x804EB09: free_foreign_masters (port.c:287) ==10651== by 0x804FB14: port_disable (port.c:722) ==10651== by 0x8051228: port_dispatch (port.c:1298) ==10651== by 0x804B3C6: clock_poll (clock.c:602) ==10651== by 0x80498AE: main (ptp4l.c:278) Signed-off-by: Richard Cochran --- port.c | 1 + 1 file changed, 1 insertion(+) diff --git a/port.c b/port.c index 2e00ffb..ef6a238 100644 --- a/port.c +++ b/port.c @@ -719,6 +719,7 @@ static void port_disable(struct port *p) p->peer_delay_fup = NULL; } + p->best = NULL; free_foreign_masters(p); clock_remove_fda(p->clock, p, p->fda); transport_close(p->trp, &p->fda);