]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
perf symbols: Check if a struct machine instance was found
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 10 May 2010 00:14:07 +0000 (21:14 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 10 May 2010 00:14:07 +0000 (21:14 -0300)
Which can happen when processing old files that had no fake kernel MMAP,
events.

That shouldn't result in perf_session__create_kernel_maps not being
called, this will be fixed in a followup patch, for now do these checks
to avoid segfaulting.

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/event.c

index 46563e16c3f50f5f3e39509abc471a522d4cfd55..dfc8bf64d70fefb5bfc454cb5583e77363f01205 100644 (file)
@@ -493,8 +493,10 @@ int event__process_mmap(event_t *self, struct perf_session *session)
                return 0;
        }
 
-       thread = perf_session__findnew(session, self->mmap.pid);
        machine = perf_session__find_host_machine(session);
+       if (machine == NULL)
+               goto out_problem;
+       thread = perf_session__findnew(session, self->mmap.pid);
        map = map__new(&machine->user_dsos, self->mmap.start,
                        self->mmap.len, self->mmap.pgoff,
                        self->mmap.pid, self->mmap.filename,
@@ -552,6 +554,10 @@ void thread__find_addr_map(struct thread *self,
        if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
                al->level = 'k';
                machine = perf_session__find_host_machine(session);
+               if (machine == NULL) {
+                       al->map = NULL;
+                       return;
+               }
                mg = &machine->kmaps;
        } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
                al->level = '.';
@@ -559,7 +565,7 @@ void thread__find_addr_map(struct thread *self,
        } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
                al->level = 'g';
                machine = perf_session__find_machine(session, pid);
-               if (!machine) {
+               if (machine == NULL) {
                        al->map = NULL;
                        return;
                }