perf kmaps: Check kmaps to make code more robust
This patch add checks in places where map__kmap is used to get kmaps from struct kmap. Error messages are added at map__kmap to warn invalid accessing of kmap (for the case of !map->dso->kernel, kmap(map) does not exists at all). Also, introduces map__kmaps() to warn uninitialized kmaps. Reviewed-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: pi3orama@163.com Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/1428394966-131044-2-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
8ea92ceb74
commit
ba92732e98
7 changed files with 70 additions and 16 deletions
|
@ -679,6 +679,9 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
|
|||
machine->vmlinux_maps[type]->unmap_ip =
|
||||
identity__map_ip;
|
||||
kmap = map__kmap(machine->vmlinux_maps[type]);
|
||||
if (!kmap)
|
||||
return -1;
|
||||
|
||||
kmap->kmaps = &machine->kmaps;
|
||||
map_groups__insert(&machine->kmaps,
|
||||
machine->vmlinux_maps[type]);
|
||||
|
@ -700,7 +703,7 @@ void machine__destroy_kernel_maps(struct machine *machine)
|
|||
kmap = map__kmap(machine->vmlinux_maps[type]);
|
||||
map_groups__remove(&machine->kmaps,
|
||||
machine->vmlinux_maps[type]);
|
||||
if (kmap->ref_reloc_sym) {
|
||||
if (kmap && kmap->ref_reloc_sym) {
|
||||
/*
|
||||
* ref_reloc_sym is shared among all maps, so free just
|
||||
* on one of them.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue