]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix memory leak and possible double-free in hashmap__clear
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 Apr 2020 01:21:04 +0000 (18:21 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Apr 2020 02:48:05 +0000 (19:48 -0700)
commit61fcaa1c0fdc22d2a7522a3883212ccfba4fc9f2
treecddf013296aff40219e40f654f9c212bd1f070c9
parent982c3b7b0b293f68c7134db69e8dbb3c47e2b9f6
libbpf: Fix memory leak and possible double-free in hashmap__clear

Fix memory leak in hashmap_clear() not freeing hashmap_entry structs for each
of the remaining entries. Also NULL-out bucket list to prevent possible
double-free between hashmap__clear() and hashmap__free().

Running test_progs-asan flavor clearly showed this problem.

Reported-by: Alston Tang <alston64@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429012111.277390-5-andriin@fb.com
tools/lib/bpf/hashmap.c