diff options
| author | 2016-09-20 23:20:32 +0200 | |
|---|---|---|
| committer | 2016-09-20 23:20:32 +0200 | |
| commit | 464b5847e61085f81bb99ce48eb427a0dc7617dc (patch) | |
| tree | 805c97855a9a13c06910687bbbbe3eb7bc371902 /kernel/events/ring_buffer.c | |
| parent | Merge branch 'irq/for-block' into irq/core (diff) | |
| parent | irqchip/mips-gic: Fix local interrupts (diff) | |
| download | linux-dev-464b5847e61085f81bb99ce48eb427a0dc7617dc.tar.xz linux-dev-464b5847e61085f81bb99ce48eb427a0dc7617dc.zip | |
Merge branch 'irq/urgent' into irq/core
Merge urgent fixes so pending patches for 4.9 can be applied.
Diffstat (limited to 'kernel/events/ring_buffer.c')
| -rw-r--r-- | kernel/events/ring_buffer.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index ae9b90dc9a5a..257fa460b846 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -330,15 +330,22 @@ void *perf_aux_output_begin(struct perf_output_handle *handle, if (!rb) return NULL; - if (!rb_has_aux(rb) || !atomic_inc_not_zero(&rb->aux_refcount)) + if (!rb_has_aux(rb)) goto err; /* - * If rb::aux_mmap_count is zero (and rb_has_aux() above went through), - * the aux buffer is in perf_mmap_close(), about to get freed. + * If aux_mmap_count is zero, the aux buffer is in perf_mmap_close(), + * about to get freed, so we leave immediately. + * + * Checking rb::aux_mmap_count and rb::refcount has to be done in + * the same order, see perf_mmap_close. Otherwise we end up freeing + * aux pages in this path, which is a bug, because in_atomic(). */ if (!atomic_read(&rb->aux_mmap_count)) - goto err_put; + goto err; + + if (!atomic_inc_not_zero(&rb->aux_refcount)) + goto err; /* * Nesting is not supported for AUX area, make sure nested |
