Skip to content

Commit

Permalink
Drop the reference to best when freeing the foreign masters.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
richardcochran committed Aug 28, 2012
1 parent 2040933 commit 852d587
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 852d587

Please sign in to comment.