Skip to content

Commit

Permalink
perf maps: Add missing unlock to maps__insert() error case
Browse files Browse the repository at this point in the history
`tools/perf/util/map.c` has a function named `maps__insert` that
acquires a write lock if its in multithread context.

Even though this lock is released when function successfully completes,
there's a branch that is executed when `maps_by_name == NULL` that
returns from this function without releasing the write lock.

Added an `up_write` to release the lock when this happens.

Fixes: a7c2b57 ("perf map_groups: Auto sort maps by name, if needed")
Signed-off-by: Cengiz Can <cengiz@kernel.wtf>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/20200120141553.23934-1-cengiz@kernel.wtf
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Cengiz Can authored and Arnaldo Carvalho de Melo committed Jan 31, 2020
1 parent 1873f15 commit 85fc95d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ void maps__insert(struct maps *maps, struct map *map)

if (maps_by_name == NULL) {
__maps__free_maps_by_name(maps);
up_write(&maps->lock);
return;
}

Expand Down

0 comments on commit 85fc95d

Please sign in to comment.