Date: Fri, 4 Aug 2017 08:12:19 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322042 - stable/11/lib/libc/x86/sys Message-ID: <201708040812.v748CJIZ015960@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Aug 4 08:12:19 2017 New Revision: 322042 URL: https://svnweb.freebsd.org/changeset/base/322042 Log: MFC r321652: Simplify flow control. Modified: stable/11/lib/libc/x86/sys/__vdso_gettc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/x86/sys/__vdso_gettc.c ============================================================================== --- stable/11/lib/libc/x86/sys/__vdso_gettc.c Fri Aug 4 04:23:23 2017 (r322041) +++ stable/11/lib/libc/x86/sys/__vdso_gettc.c Fri Aug 4 08:12:19 2017 (r322042) @@ -146,25 +146,24 @@ __vdso_init_hpet(uint32_t u) if (old_map != NULL) return; - if (cap_getmode(&mode) == 0 && mode != 0) - 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; + } - fd = _open(devname, O_RDONLY); - if (fd == -1) - goto fail; - new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0); _close(fd); if (atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708040812.v748CJIZ015960>