libbpf: Fix removal of inner map in bpf_object__create_map
authorMartynas Pumputis <m@lambda.lt>
Mon, 19 Jul 2021 17:38:37 +0000 (19:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:50:32 +0000 (09:50 +0200)
commit8c3b5028ec02924f3b037a6d07124a006a9a3c4f
treeee5075e19d4a7280c9c9d7041bea5b94d8c9d71c
parentffb887c15f7ff2b0cfb7fb2e7e288b4a3bf4f604
libbpf: Fix removal of inner map in bpf_object__create_map

[ Upstream commit a21ab4c59e09c2a9994a6e393b7484e3b3f78a99 ]

If creating an outer map of a BTF-defined map-in-map fails (via
bpf_object__create_map()), then the previously created its inner map
won't be destroyed.

Fix this by ensuring that the destroy routines are not bypassed in the
case of a failure.

Fixes: 646f02ffdd49c ("libbpf: Add BTF-defined map-in-map support")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Martynas Pumputis <m@lambda.lt>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210719173838.423148-2-m@lambda.lt
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/libbpf.c