Skip to content

Commit 71e7bc2

Browse files
David Carrillo-CisnerosIngo Molnar
authored andcommitted
perf/core: Check return value of the perf_event_read() IPI
The call to smp_call_function_single in perf_event_read() may fail if an invalid or not online CPU index is passed. Warn user if such bug is present and return error. Signed-off-by: David Carrillo-Cisneros <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul Turner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vegard Nossum <[email protected]> Cc: Vince Weaver <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 99f5bc9 commit 71e7bc2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/events/core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,9 +3549,10 @@ static int perf_event_read(struct perf_event *event, bool group)
35493549
.group = group,
35503550
.ret = 0,
35513551
};
3552-
smp_call_function_single(event->oncpu,
3553-
__perf_event_read, &data, 1);
3554-
ret = data.ret;
3552+
ret = smp_call_function_single(event->oncpu, __perf_event_read, &data, 1);
3553+
/* The event must have been read from an online CPU: */
3554+
WARN_ON_ONCE(ret);
3555+
ret = ret ? : data.ret;
35553556
} else if (event->state == PERF_EVENT_STATE_INACTIVE) {
35563557
struct perf_event_context *ctx = event->ctx;
35573558
unsigned long flags;

0 commit comments

Comments
 (0)