• F
    perf: Sanitize get_callchain_buffer() · 90983b16
    Frederic Weisbecker 提交于
    In case of allocation failure, get_callchain_buffer() keeps the
    refcount incremented for the current event.
    
    As a result, when get_callchain_buffers() returns an error,
    we must cleanup what it did by cancelling its last refcount
    with a call to put_callchain_buffers().
    
    This is a hack in order to be able to call free_event()
    after that failure.
    
    The original purpose of that was to simplify the failure
    path. But this error handling is actually counter intuitive,
    ugly and not very easy to follow because one expect to
    see the resources used to perform a service to be cleaned
    by the callee if case of failure, not by the caller.
    
    So lets clean this up by cancelling the refcount from
    get_callchain_buffer() in case of failure. And correctly free
    the event accordingly in perf_event_alloc().
    Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Stephane Eranian <eranian@google.com>
    Signed-off-by: NPeter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1374539466-4799-3-git-send-email-fweisbec@gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
    90983b16
core.c 182.3 KB