diff mbox series

rtla/osnoise: avoid NULL pointer dereference on out

Message ID 1648623748-8833-1-git-send-email-baihaowen@meizu.com (mailing list archive)
State Superseded
Headers show
Series rtla/osnoise: avoid NULL pointer dereference on out | expand

Commit Message

baihaowen March 30, 2022, 7:02 a.m. UTC
record is NULL and go out but dereference record->trace.

report by coccicheck:
tools/tracing/rtla/src/osnoise_top.c:650:31-36: ERROR:
record is NULL but dereferenced.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 tools/tracing/rtla/src/osnoise_top.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Daniel Bristot de Oliveira March 31, 2022, 12:27 p.m. UTC | #1
On 3/30/22 09:02, Haowen Bai wrote:
> record is NULL and go out but dereference record->trace.
> 
> report by coccicheck:
> tools/tracing/rtla/src/osnoise_top.c:650:31-36: ERROR:
> record is NULL but dereferenced.

Duplicated of:
https://lore.kernel.org/lkml/20220322113253.57390-1-wanjiabing@vivo.com/

-- Daniel
diff mbox series

Patch

diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 72c2fd6..8cb185e 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -572,7 +572,7 @@  int osnoise_top_main(int argc, char **argv)
 	retval = osnoise_top_apply_config(tool, params);
 	if (retval) {
 		err_msg("Could not apply config\n");
-		goto out_top;
+		goto out_top_pre;
 	}
 
 	trace = &tool->trace;
@@ -580,14 +580,14 @@  int osnoise_top_main(int argc, char **argv)
 	retval = enable_osnoise(trace);
 	if (retval) {
 		err_msg("Failed to enable osnoise tracer\n");
-		goto out_top;
+		goto out_top_pre;
 	}
 
 	if (params->set_sched) {
 		retval = set_comm_sched_attr("osnoise/", &params->sched_param);
 		if (retval) {
 			err_msg("Failed to set sched parameters\n");
-			goto out_top;
+			goto out_top_pre;
 		}
 	}
 
@@ -597,7 +597,7 @@  int osnoise_top_main(int argc, char **argv)
 		record = osnoise_init_trace_tool("osnoise");
 		if (!record) {
 			err_msg("Failed to enable the trace instance\n");
-			goto out_top;
+			goto out_top_pre;
 		}
 
 		if (params->events) {
@@ -648,6 +648,7 @@  int osnoise_top_main(int argc, char **argv)
 
 out_top:
 	trace_events_destroy(&record->trace, params->events);
+out_top_pre:
 	params->events = NULL;
 	osnoise_free_top(tool->data);
 	osnoise_destroy_tool(record);