Skip to content

Commit

Permalink
perf maps: Fix map__clone() for struct kmap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Feb 11, 2020
1 parent 4a4eb61 commit 7ce6613
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,13 @@ struct symbol *map__find_symbol_by_name(struct map *map, const char *name)

struct map *map__clone(struct map *from)
{
struct map *map = memdup(from, sizeof(*map));
size_t size = sizeof(struct map);
struct map *map;

if (from->dso && from->dso->kernel)
size += sizeof(struct kmap);

map = memdup(from, size);
if (map != NULL) {
refcount_set(&map->refcnt, 1);
RB_CLEAR_NODE(&map->rb_node);
Expand Down

0 comments on commit 7ce6613

Please sign in to comment.