OSDN Git Service

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)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 19 Jul 2021 22:48:20 +0000 (15:48 -0700)
commita21ab4c59e09c2a9994a6e393b7484e3b3f78a99
tree5a6fd6fbc93e3cea9b9322980972ab28238da08d
parent78e4a955928ef4a3e68cc371ac8c70fd150f873b
libbpf: Fix removal of inner map in bpf_object__create_map

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
tools/lib/bpf/libbpf.c