summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-08-04 08:12:19 +0000
committerkib <kib@FreeBSD.org>2017-08-04 08:12:19 +0000
commitef8e2a06ba6bf4731ef10fa2ca98bdb144a1402c (patch)
tree7753220044e719983653c8a36f86b29bf7038557 /lib
parentdeb2c537f5ca5924fc0060f8bb3f7d5ef2b0772d (diff)
downloadFreeBSD-src-ef8e2a06ba6bf4731ef10fa2ca98bdb144a1402c.zip
FreeBSD-src-ef8e2a06ba6bf4731ef10fa2ca98bdb144a1402c.tar.gz
MFC r321652:
Simplify flow control.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/x86/sys/__vdso_gettc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 16af7d8..ad84b02 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -146,12 +146,17 @@ __vdso_init_hpet(uint32_t u)
if (old_map != NULL)
return;
- if (cap_getmode(&mode) == 0 && mode != 0)
- goto fail;
-
- fd = _open(devname, O_RDONLY);
- if (fd == -1)
- goto fail;
+ /*
+ * Explicitely check for the capability mode to avoid
+ * triggering trap_enocap on the device open by absolute path.
+ */
+ if ((cap_getmode(&mode) == 0 && mode != 0) ||
+ (fd = _open(devname, O_RDONLY)) == -1) {
+ /* Prevent the caller from re-entering. */
+ atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
+ (uintptr_t)old_map, (uintptr_t)MAP_FAILED);
+ return;
+ }
new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
_close(fd);
@@ -159,12 +164,6 @@ __vdso_init_hpet(uint32_t u)
(uintptr_t)old_map, (uintptr_t)new_map) == 0 &&
new_map != MAP_FAILED)
munmap((void *)new_map, PAGE_SIZE);
-
- return;
-fail:
- /* Prevent the caller from re-entering. */
- atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
- (uintptr_t)old_map, (uintptr_t)MAP_FAILED);
}
#ifdef WANT_HYPERV
OpenPOWER on IntegriCloud