[llvm] r311567 - bpf: close the file descriptor after probe inside getHostCPUNameForBPF
Yonghong Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 09:24:31 PDT 2017
Author: yhs
Date: Wed Aug 23 09:24:31 2017
New Revision: 311567
URL: http://llvm.org/viewvc/llvm-project?rev=311567&view=rev
Log:
bpf: close the file descriptor after probe inside getHostCPUNameForBPF
Signed-off-by: Yonghong Song <yhs at fb.com>
Modified:
llvm/trunk/lib/Support/Host.cpp
Modified: llvm/trunk/lib/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=311567&r1=311566&r2=311567&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Host.cpp (original)
+++ llvm/trunk/lib/Support/Host.cpp Wed Aug 23 09:24:31 2017
@@ -300,7 +300,11 @@ StringRef sys::detail::getHostCPUNameFor
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
}
More information about the llvm-commits
mailing list