trace-cmd library: Do not read if cpu is greater than cpus
PATCH 1/1 trace-cmd library: Do not read if cpu is greater than cpus
From: "Steven Rostedt (Google)" <[email protected]>
Fix tracecmd_read_data() to not read a cpu if it is greater than the number of CPUs recorded.
As tracecmd_cpus() returns the number of CPUs found in the system which can be greater than the number of CPUs stored in the buffer, it is likely that a caller will pass in a CPU number that is greater than the stored array of cpu_data.
In this case return NULL otherwise it will access beyond the cpu_data array.
Fixes 8724996990021 ("trace-cmd library: Read extended BUFFER option")
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- lib/trace-cmd/trace-input.c | 3 +++ 1 file changed, 3 insertions(+)
lib/trace-cmd/trace-input.c +3 -0
@@ -2462,6 +2462,9 @@ tracecmd_read_data(struct tracecmd_input *handle, int cpu) {struct tep_record *record; +if (cpu >= handle->cpus) +return NULL ; + record =tracecmd_peek_data (handle, cpu); handle->cpu_data[cpu].next =NULL ;if (record) {
Signature · 1 line
2.35.1