libbpf: Refactor cleanup in ring_buffer__add
authorMartin Kelly <martin.kelly@crowdstrike.com>
Mon, 25 Sep 2023 21:50:32 +0000 (14:50 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 25 Sep 2023 23:22:42 +0000 (16:22 -0700)
commit4448f64c549c28175dd9af4e8f9a2e0c62ef6d38
treea99117dde3b9d965c92594e16f65b6c3632060ca
parent831916fb93d4b99bd5f18b8530708b88d901a522
libbpf: Refactor cleanup in ring_buffer__add

Refactor the cleanup code in ring_buffer__add to use a unified err_out
label. This reduces code duplication, as well as plugging a potential
leak if mmap_sz != (__u64)(size_t)mmap_sz (currently this would miss
unmapping tmp because ringbuf_unmap_ring isn't called).

Signed-off-by: Martin Kelly <martin.kelly@crowdstrike.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230925215045.2375758-2-martin.kelly@crowdstrike.com
tools/lib/bpf/ringbuf.c