From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> If tracefs_cpu_read() has an error, it will return a negative value. But the value is then used as an index. An error check is required to make sure that if an error is returned from tracefs_cpu_read() the function exits with that error and does not continue further. Fixes: 2610bdcde ("trace-cmd library: Use tracefs_cpu for recorder helpers") Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- lib/trace-cmd/trace-recorder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c index 79b95ce1193d..db159e5e5d14 100644 --- a/lib/trace-cmd/trace-recorder.c +++ b/lib/trace-cmd/trace-recorder.c @@ -323,6 +323,8 @@ static long read_data(struct tracecmd_recorder *recorder) long r, w; r = tracefs_cpu_read(recorder->tcpu, buf, nonblock); + if (r < 0) + return r; left = r; do { -- 2.35.1