From: Yonghong Song Date: Wed, 23 Aug 2017 16:24:31 +0000 (+0000) Subject: bpf: close the file descriptor after probe inside getHostCPUNameForBPF X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0ef4bebe95dd81d1220d768e77983028647563b;p=llvm bpf: close the file descriptor after probe inside getHostCPUNameForBPF Signed-off-by: Yonghong Song git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311567 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index aa1c4aeaf21..ad16b02a116 100644 --- a/lib/Support/Host.cpp +++ b/lib/Support/Host.cpp @@ -300,7 +300,11 @@ StringRef sys::detail::getHostCPUNameForBPF() { attr.license = (uint64_t)"DUMMY"; int fd = syscall(321 /* __NR_bpf */, 5 /* BPF_PROG_LOAD */, &attr, sizeof(attr)); - return (fd > 0) ? "v2" : "v1"; + if (fd >= 0) { + close(fd); + return "v2"; + } + return "v1"; #endif }