The actions_add_trace_output() function can fail if it's unable to
allocate memory for a new action. Currently, the return value is not
checked, and the program continues to run, which can lead to
unexpected behavior.
Add a check to the return value of actions_add_trace_output() and
exit with a proper error message if it fails.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
tools/tracing/rtla/src/timerlat_hist.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index f14fc56c5b4a5..39a14c4e07de8 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -1070,8 +1070,10 @@ static struct common_params
}
}
- if (trace_output)
- actions_add_trace_output(¶ms->common.threshold_actions, trace_output);
+ if (trace_output && actions_add_trace_output(¶ms->common.threshold_actions, trace_output)) {
+ err_msg("Could not add a new trace output");
+ exit(EXIT_FAILURE);
+ }
if (geteuid()) {
err_msg("rtla needs root permission\n");
--
2.51.1