The error path does not clean up properly when allocations fail. This patch fixes the memory leaks on the error path.
Signed-off-by: Richard Cochran <richardcoch...@gmail.com> --- ts2phc_nmea_master.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ts2phc_nmea_master.c b/ts2phc_nmea_master.c index 76fc7ae..5c17e5a 100644 --- a/ts2phc_nmea_master.c +++ b/ts2phc_nmea_master.c @@ -220,6 +220,7 @@ struct ts2phc_master *ts2phc_nmea_master_create(struct config *cfg, const char * } master->lstab = lstab_create(leapfile); if (!master->lstab) { + free(master); return NULL; } master->master.destroy = ts2phc_nmea_master_destroy; @@ -229,6 +230,7 @@ struct ts2phc_master *ts2phc_nmea_master_create(struct config *cfg, const char * err = pthread_create(&master->worker, NULL, monitor_nmea_status, master); if (err) { pr_err("failed to create worker thread: %s", strerror(err)); + lstab_destroy(master->lstab); free(master); return NULL; } -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel