From 60317a6780c4e4e546cca092479059b042e5ea25 Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Mon, 15 Jul 2024 14:12:52 +0000 Subject: [PATCH] chore(engine/bpf): close only used fds Signed-off-by: Roberto Scolaro --- userspace/libscap/engine/bpf/scap_bpf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c index 0d4385751c..29430a382f 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.c +++ b/userspace/libscap/engine/bpf/scap_bpf.c @@ -1386,8 +1386,11 @@ int32_t scap_bpf_close(struct scap_engine_handle engine) for(int i = 0; i < BPF_MAPS_MAX; i++) { - close(handle->m_bpf_map_fds[i]); - handle->m_bpf_map_fds[i] = -1; + if(handle->m_bpf_map_fds[i] >= 0) + { + close(handle->m_bpf_map_fds[i]); + handle->m_bpf_map_fds[i] = -1; + } } return SCAP_SUCCESS;