The pointer results is allocated in tracecmd_msg_recv_time_sync(). It isn't freed if ptp_clock_server() exits with an error. Free it in the error path. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- lib/trace-cmd/trace-timesync-ptp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/trace-cmd/trace-timesync-ptp.c b/lib/trace-cmd/trace-timesync-ptp.c index 20e6e6f1..402edeb2 100644 --- a/lib/trace-cmd/trace-timesync-ptp.c +++ b/lib/trace-cmd/trace-timesync-ptp.c @@ -608,8 +608,10 @@ static int ptp_clock_server(struct tracecmd_time_sync *tsync, sync_proto, &sync_msg, &size, (char **)&results); if (ret || strncmp(sync_proto, PTP_NAME, TRACECMD_TSYNC_PNAME_LENGTH) || - sync_msg != PTP_SYNC_PKT_PROBES || size == 0 || results == NULL) + sync_msg != PTP_SYNC_PKT_PROBES || size == 0 || results == NULL) { + free(results); return -1; + } ntoh_ptp_results(results); if (ptp->flags & PTP_FLAG_USE_MARKER) -- 2.44.0