mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
perf script: Check session->header.env.arch before using it
commit 29c77550eef31b0d72a45b49eeab03b8963264e8 upstream. When perf.data is not written cleanly, we would like to process existing data as much as possible (please see f_header.data.size == 0 condition in perf_session__read_header). However, perf.data with partial data may crash perf. Specifically, we see crash in 'perf script' for NULL session->header.env.arch. Fix this by checking session->header.env.arch before using it to determine native_arch. Also split the if condition so it is easier to read. Committer notes: If it is a pipe, we already assume is a native arch, so no need to check session->header.env.arch. Signed-off-by: Song Liu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
472d9354a9
commit
39fb393e21
1 changed files with 8 additions and 4 deletions
|
|
@ -3779,11 +3779,15 @@ int cmd_script(int argc, const char **argv)
|
|||
goto out_delete;
|
||||
|
||||
uname(&uts);
|
||||
if (data.is_pipe || /* assume pipe_mode indicates native_arch */
|
||||
!strcmp(uts.machine, session->header.env.arch) ||
|
||||
(!strcmp(uts.machine, "x86_64") &&
|
||||
!strcmp(session->header.env.arch, "i386")))
|
||||
if (data.is_pipe) { /* Assume pipe_mode indicates native_arch */
|
||||
native_arch = true;
|
||||
} else if (session->header.env.arch) {
|
||||
if (!strcmp(uts.machine, session->header.env.arch))
|
||||
native_arch = true;
|
||||
else if (!strcmp(uts.machine, "x86_64") &&
|
||||
!strcmp(session->header.env.arch, "i386"))
|
||||
native_arch = true;
|
||||
}
|
||||
|
||||
script.session = session;
|
||||
script__setup_sample_type(&script);
|
||||
|
|
|
|||
Loading…
Reference in a new issue