In tracecmd_tsync_proto_getall() if the allocation plist succeeded but the allocation of plist->names didn't, the function just returns without freeing plist. There is already a proper exit path that free allocated ressource: just use it. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- lib/trace-cmd/trace-timesync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c index 75c27bab..6ee4e643 100644 --- a/lib/trace-cmd/trace-timesync.c +++ b/lib/trace-cmd/trace-timesync.c @@ -290,7 +290,7 @@ int tracecmd_tsync_proto_getall(struct tracecmd_tsync_protos **protos, const cha goto error; plist->names = calloc(count, sizeof(char *)); if (!plist->names) - return -1; + goto error; for (i = 0, proto = tsync_proto_list; proto && i < (count - 1); proto = proto->next) { if (!(proto->roles & role)) -- 2.44.0