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 <mlichvar@redhat.com>
master
Miroslav Lichvar 2018-08-09 17:53:04 +02:00 committed by Richard Cochran
parent d08bee2771
commit 47971bdd50
1 changed files with 2 additions and 1 deletions

3
port.c
View File

@ -914,6 +914,7 @@ static int port_management_fill_response(struct port *target,
break; break;
default: default:
/* The caller should *not* respond to this message. */ /* The caller should *not* respond to this message. */
tlv_extra_recycle(extra);
return 0; return 0;
} }
@ -2844,7 +2845,7 @@ struct port *port_open(int phc_index,
p->event = e2e_event; p->event = e2e_event;
break; break;
case CLOCK_TYPE_MANAGEMENT: case CLOCK_TYPE_MANAGEMENT:
return NULL; goto err_port;
} }
p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm; p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm;