File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -330,15 +330,22 @@ void *perf_aux_output_begin(struct perf_output_handle *handle,
330
330
if (!rb )
331
331
return NULL ;
332
332
333
- if (!rb_has_aux (rb ) || ! atomic_inc_not_zero ( & rb -> aux_refcount ) )
333
+ if (!rb_has_aux (rb ))
334
334
goto err ;
335
335
336
336
/*
337
- * If rb::aux_mmap_count is zero (and rb_has_aux() above went through),
338
- * the aux buffer is in perf_mmap_close(), about to get freed.
337
+ * If aux_mmap_count is zero, the aux buffer is in perf_mmap_close(),
338
+ * about to get freed, so we leave immediately.
339
+ *
340
+ * Checking rb::aux_mmap_count and rb::refcount has to be done in
341
+ * the same order, see perf_mmap_close. Otherwise we end up freeing
342
+ * aux pages in this path, which is a bug, because in_atomic().
339
343
*/
340
344
if (!atomic_read (& rb -> aux_mmap_count ))
341
- goto err_put ;
345
+ goto err ;
346
+
347
+ if (!atomic_inc_not_zero (& rb -> aux_refcount ))
348
+ goto err ;
342
349
343
350
/*
344
351
* Nesting is not supported for AUX area, make sure nested
You can’t perform that action at this time.
0 commit comments