Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf maps: Fix map__clone() for struct kmap

The map__clone() function can be called on kernel maps as well, so it
needs to duplicate the whole kmap data.

Reported-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Kim Phillips <kim.phillips@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200210143218.24948-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
7ce66139 4a4eb615

+6 -1
+6 -1
tools/perf/util/map.c
··· 375 375 376 376 struct map *map__clone(struct map *from) 377 377 { 378 - struct map *map = memdup(from, sizeof(*map)); 378 + size_t size = sizeof(struct map); 379 + struct map *map; 379 380 381 + if (from->dso && from->dso->kernel) 382 + size += sizeof(struct kmap); 383 + 384 + map = memdup(from, size); 380 385 if (map != NULL) { 381 386 refcount_set(&map->refcnt, 1); 382 387 RB_CLEAR_NODE(&map->rb_node);