Use the tracefs_list_free() for cleaning lists of events and systems, returned by tracefs_system_events() and tracefs_event_systems() APIs. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- lib/tracefs/tracefs-events.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/tracefs/tracefs-events.c b/lib/tracefs/tracefs-events.c index 8e825f50..6b796382 100644 --- a/lib/tracefs/tracefs-events.c +++ b/lib/tracefs/tracefs-events.c @@ -481,11 +481,7 @@ next_event: failure = ret; } - if (events) { - for (i = 0; events[i]; i++) - free(events[i]); - free(events); - } + tracefs_list_free(events); return failure; } @@ -564,11 +560,7 @@ static int fill_local_events_system(const char *tracing_dir, /* always succeed because parsing failures are not critical */ ret = 0; out: - if (systems) { - for (i = 0; systems[i]; i++) - free(systems[i]); - free(systems); - } + tracefs_list_free(systems); return ret; } -- 2.28.0