When we fail to allocate the callchain buffers, we rollback the refcount we did and return from get_callchain_buffers().
However we take the refcount and allocate under the callchain lock but the rollback is done outside the lock. As a result, while we rollback, some concurrent callchain user may call get_callchain_buffers(), see the non-zero refcount and give up because the buffers are NULL without itself retrying the allocation. The consequences aren't that bad but that behaviour looks weird enough and it's better to give their chances to the following callchain users where we failed. Reported-by: Jiri Olsa <jo...@redhat.com> Signed-off-by: Frederic Weisbecker <fweis...@gmail.com> Cc: Ingo Molnar <mi...@kernel.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Jiri Olsa <jo...@redhat.com> Cc: Namhyung Kim <namhy...@kernel.org> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Stephane Eranian <eran...@google.com> --- kernel/events/callchain.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index 76a8bc5..97b67df 100644 --- a/kernel/events/callchain.c +++ b/kernel/events/callchain.c @@ -116,10 +116,11 @@ int get_callchain_buffers(void) err = alloc_callchain_buffers(); exit: - mutex_unlock(&callchain_mutex); if (err) atomic_dec(&nr_callchain_events); + mutex_unlock(&callchain_mutex); + return err; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/