• Leo Yan's avatar
    perf auxtrace: Fix potential NULL pointer dereference · b14585d9
    Leo Yan authored
    In the function auxtrace_parse_snapshot_options(), the callback pointer
    "itr->parse_snapshot_options" can be NULL if it has not been set during
    the AUX record initialization.  This can cause tool crashing if the
    callback pointer "itr->parse_snapshot_options" is dereferenced without
    performing NULL check.
    
    Add a NULL check for the pointer "itr->parse_snapshot_options" before
    invoke the callback.
    
    Fixes: d20031bb
    
     ("perf tools: Add AUX area tracing Snapshot Mode")
    Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
    Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
    Link: http://lore.kernel.org/lkml/20210420151554.2031768-1-leo....
    b14585d9
auxtrace.c 59 KB