From 47971bdd50d234305cce95da5a544a4f3b8d0f2f Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 9 Aug 2018 17:53:04 +0200 Subject: [PATCH] port: Fix memory leaks. In port_management_fill_response() the TLV descriptor leaked when not responding. In port_open() the port would leak with the unsupported management clock type. Signed-off-by: Miroslav Lichvar --- port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index 6f5408e..5e0aed7 100644 --- a/port.c +++ b/port.c @@ -914,6 +914,7 @@ static int port_management_fill_response(struct port *target, break; default: /* The caller should *not* respond to this message. */ + tlv_extra_recycle(extra); return 0; } @@ -2844,7 +2845,7 @@ struct port *port_open(int phc_index, p->event = e2e_event; break; case CLOCK_TYPE_MANAGEMENT: - return NULL; + goto err_port; } p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm;