[PATCH] tracing: Fix possible memory leak in __create_synth_event

From: Miaoqian Lin
Date: Fri Nov 26 2021 - 06:28:20 EST


Before goto err, call argv_free to handle argv in order to prevent
memory leak.

Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx>
---
kernel/trace/trace_events_synth.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 22db3ce95e74..fe2e37564c9b 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -1261,6 +1261,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
*/
if (cmd_version > 1 && n_fields_this_loop >= 1) {
synth_err(SYNTH_ERR_INVALID_CMD, errpos(field_str));
+ argv_free(argv);
ret = -EINVAL;
goto err;
}
@@ -1268,6 +1269,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
fields[n_fields++] = field;
if (n_fields == SYNTH_FIELDS_MAX) {
synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0);
+ argv_free(argv);
ret = -EINVAL;
goto err;
}
@@ -1277,6 +1279,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)

if (consumed < argc) {
synth_err(SYNTH_ERR_INVALID_CMD, 0);
+ argv_free(argv);
ret = -EINVAL;
goto err;
}
--
2.17.1