Free tmp_var in the error path. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- src/tracefs-hist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index 87287b5..4f4971e 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -1576,7 +1576,7 @@ int tracefs_synth_add_end_field(struct tracefs_synth *synth, const struct tep_format_field *field; const char *hname = NULL; char *tmp_var = NULL; - int ret; + int ret = -1; if (!synth || !end_field) { errno = EINVAL; @@ -1594,15 +1594,15 @@ int tracefs_synth_add_end_field(struct tracefs_synth *synth, tmp_var = new_arg(synth); if (!trace_verify_event_field(synth->end_event, end_field, &field)) - return -1; + goto out; ret = add_var(&synth->end_vars, name ? hname : tmp_var, end_field, false); if (ret) goto out; ret = add_synth_fields(synth, field, name, hname ? : tmp_var); - free(tmp_var); out: + free(tmp_var); return ret; } -- 2.44.0