On Wed, 5 Jun 2024 15:40:44 +0200 "Jerome Marchand" <jmarchan@xxxxxxxxxx> wrote: > Because of the again label, msg_handle can be already allocated if we > exit after we got a negative socket file descriptor. Free it there. > > Fixes a RESOURCE_LEAK error (CWE-772) > > Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> > --- > tracecmd/trace-record.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c > index b4cbd438..770e775b 100644 > --- a/tracecmd/trace-record.c > +++ b/tracecmd/trace-record.c > @@ -3903,6 +3903,7 @@ static struct tracecmd_msg_handle *setup_network(struct buffer_instance *instanc > > if (sfd < 0) { > free(thost); > + free(msg_handle); As msg_handle is created with: msg_handle = tracecmd_msg_handle_alloc(sfd, 0); This should be: trace_msg_handle_close(msg_handle); But may require: close(sfd); + msg_handle->fd = -1; free(host); host = NULL; goto again; I'll skip this patch. -- Steve > return NULL; > } >