Message ID | 20250322183439.393533-2-costa.shul@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v1] rtla: Fix crash due to NULL record dereference | expand |
so 22. 3. 2025 v 19:40 odesÃlatel Costa Shulyupin <costa.shul@redhat.com> napsal: > > The previous patch introduced a crash by dereferencing record, > which can be NULL. > > Add checks to prevent the crash. > > Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> This is a duplicate of my fix [1]. I added a NULL check inside the function and made the callers pass NULL if the record instance is not initialized. [1] https://lore.kernel.org/linux-trace-kernel/20250313141034.299117-1-tglozar@redhat.com/ Tomas
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c index 7c6ef67ef3e6c..f94c7c049406d 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -983,7 +983,8 @@ int osnoise_hist_main(int argc, char *argv[]) if (osnoise_trace_is_off(tool, record)) { printf("rtla osnoise hit stop tracing\n"); - save_trace_to_file(record->trace.inst, params->trace_output); + if (record) + save_trace_to_file(record->trace.inst, params->trace_output); } out_hist: diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c index 0eeefbbbf3173..003c0f76b1ada 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -813,7 +813,8 @@ int osnoise_top_main(int argc, char **argv) if (osnoise_trace_is_off(tool, record)) { printf("osnoise hit stop tracing\n"); - save_trace_to_file(record->trace.inst, params->trace_output); + if (record) + save_trace_to_file(record->trace.inst, params->trace_output); } out_top: diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 93d0c9e450204..f91efe8804586 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -1473,7 +1473,8 @@ int timerlat_hist_main(int argc, char *argv[]) if (!params->no_aa) timerlat_auto_analysis(params->stop_us, params->stop_total_us); - save_trace_to_file(record->trace.inst, params->trace_output); + if (record) + save_trace_to_file(record->trace.inst, params->trace_output); } out_hist: diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index 3894ac37d81ca..f082f8b91afef 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -1295,7 +1295,8 @@ int timerlat_top_main(int argc, char *argv[]) if (!params->no_aa) timerlat_auto_analysis(params->stop_us, params->stop_total_us); - save_trace_to_file(record->trace.inst, params->trace_output); + if (record) + save_trace_to_file(record->trace.inst, params->trace_output); } else if (params->aa_only) { /* * If the trace did not stop with --aa-only, at least print the
The previous patch introduced a crash by dereferencing record, which can be NULL. Add checks to prevent the crash. Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> --- tools/tracing/rtla/src/osnoise_hist.c | 3 ++- tools/tracing/rtla/src/osnoise_top.c | 3 ++- tools/tracing/rtla/src/timerlat_hist.c | 3 ++- tools/tracing/rtla/src/timerlat_top.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)