linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtla/osnoise: avoid NULL pointer dereference on out
@ 2022-03-30  7:02 Haowen Bai
  2022-03-31 12:27 ` Daniel Bristot de Oliveira
  0 siblings, 1 reply; 2+ messages in thread
From: Haowen Bai @ 2022-03-30  7:02 UTC (permalink / raw)
  To: Daniel Bristot de Oliveira, Steven Rostedt
  Cc: Haowen Bai, linux-trace-devel, linux-kernel

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(-)

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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtla/osnoise: avoid NULL pointer dereference on out
  2022-03-30  7:02 [PATCH] rtla/osnoise: avoid NULL pointer dereference on out Haowen Bai
@ 2022-03-31 12:27 ` Daniel Bristot de Oliveira
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-03-31 12:27 UTC (permalink / raw)
  To: Haowen Bai, Steven Rostedt; +Cc: linux-trace-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-31 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30  7:02 [PATCH] rtla/osnoise: avoid NULL pointer dereference on out Haowen Bai
2022-03-31 12:27 ` Daniel Bristot de Oliveira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).