* [PATCH] rtla/osnoise_hist: avoid NULL pointer dereference on out
@ 2022-03-30 7:13 Haowen Bai
2022-03-31 12:28 ` Daniel Bristot de Oliveira
0 siblings, 1 reply; 2+ messages in thread
From: Haowen Bai @ 2022-03-30 7:13 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_hist.c:870:31-36: ERROR:
record is NULL but dereferenced.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
tools/tracing/rtla/src/osnoise_hist.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index b4380d4..b7862b4 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -819,13 +819,13 @@ int osnoise_hist_main(int argc, char *argv[])
record = osnoise_init_trace_tool("osnoise");
if (!record) {
err_msg("Failed to enable the trace instance\n");
- goto out_hist;
+ goto out_top;
}
if (params->events) {
retval = trace_events_enable(&record->trace, params->events);
if (retval)
- goto out_hist;
+ goto out_top;
}
trace_instance_start(&record->trace);
@@ -845,7 +845,7 @@ int osnoise_hist_main(int argc, char *argv[])
trace);
if (retval < 0) {
err_msg("Error iterating on events\n");
- goto out_hist;
+ goto out_top;
}
if (trace_is_off(&tool->trace, &record->trace))
@@ -865,9 +865,9 @@ int osnoise_hist_main(int argc, char *argv[])
save_trace_to_file(record->trace.inst, params->trace_output);
}
}
-
-out_hist:
+out_top:
trace_events_destroy(&record->trace, params->events);
+out_hist:
params->events = NULL;
osnoise_free_histogram(tool->data);
out_destroy:
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtla/osnoise_hist: avoid NULL pointer dereference on out
2022-03-30 7:13 [PATCH] rtla/osnoise_hist: avoid NULL pointer dereference on out Haowen Bai
@ 2022-03-31 12:28 ` Daniel Bristot de Oliveira
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-03-31 12:28 UTC (permalink / raw)
To: Haowen Bai, Steven Rostedt; +Cc: linux-trace-devel, linux-kernel
On 3/30/22 09:13, Haowen Bai wrote:
> record is NULL and go out but dereference record->trace.
>
> report by coccicheck:
> tools/tracing/rtla/src/osnoise_hist.c:870:31-36: ERROR:
> record is NULL but dereferenced.
Duplicated of:
https://lore.kernel.org/lkml/20220322113253.57390-1-wanjiabing@vivo.com/
Next time, please, consolidate your patches for the same Fixes: into a single one.
Thanks,
-- Daniel
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> tools/tracing/rtla/src/osnoise_hist.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
> index b4380d4..b7862b4 100644
> --- a/tools/tracing/rtla/src/osnoise_hist.c
> +++ b/tools/tracing/rtla/src/osnoise_hist.c
> @@ -819,13 +819,13 @@ int osnoise_hist_main(int argc, char *argv[])
> record = osnoise_init_trace_tool("osnoise");
> if (!record) {
> err_msg("Failed to enable the trace instance\n");
> - goto out_hist;
> + goto out_top;
> }
>
> if (params->events) {
> retval = trace_events_enable(&record->trace, params->events);
> if (retval)
> - goto out_hist;
> + goto out_top;
> }
>
> trace_instance_start(&record->trace);
> @@ -845,7 +845,7 @@ int osnoise_hist_main(int argc, char *argv[])
> trace);
> if (retval < 0) {
> err_msg("Error iterating on events\n");
> - goto out_hist;
> + goto out_top;
> }
>
> if (trace_is_off(&tool->trace, &record->trace))
> @@ -865,9 +865,9 @@ int osnoise_hist_main(int argc, char *argv[])
> save_trace_to_file(record->trace.inst, params->trace_output);
> }
> }
> -
> -out_hist:
> +out_top:
> trace_events_destroy(&record->trace, params->events);
> +out_hist:
> params->events = NULL;
> osnoise_free_histogram(tool->data);
> out_destroy:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-31 12:29 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:13 [PATCH] rtla/osnoise_hist: avoid NULL pointer dereference on out Haowen Bai
2022-03-31 12:28 ` 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).