diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c index 7ec9ce9d..d57d2635 100644 --- a/lib/bpf_legacy.c +++ b/lib/bpf_legacy.c @@ -2992,7 +2992,7 @@ static int bpf_obj_open(const char *pathname, enum bpf_prog_type type, out: bpf_elf_ctx_destroy(ctx, ret < 0); if (ret < 0) { - if (fd) + if (fd >= 0) close(fd); return ret; }