Date: Tue, 03 Sep 2019 14:06:46 -0000 From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346158 - head/lib/libthr/thread Message-ID: <201904121727.x3CHRJnh080839@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Apr 12 17:27:19 2019 New Revision: 346158 URL: https://svnweb.freebsd.org/changeset/base/346158 Log: Do not access mutex memory after unlock. PR: 237195 Reported by: freebsd@hurrikhan.eu Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/lib/libthr/thread/thr_mutex.c Modified: head/lib/libthr/thread/thr_mutex.c ============================================================================== --- head/lib/libthr/thread/thr_mutex.c Fri Apr 12 17:11:50 2019 (r346157) +++ head/lib/libthr/thread/thr_mutex.c Fri Apr 12 17:27:19 2019 (r346158) @@ -949,7 +949,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, { struct pthread *curthread; uint32_t id; - int deferred, error, robust; + int deferred, error, private, robust; if (__predict_false(m <= THR_MUTEX_DESTROYED)) { if (m == THR_MUTEX_DESTROYED) @@ -967,6 +967,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, return (EPERM); error = 0; + private = (m->m_flags & PMUTEX_FLAG_PRIVATE) != 0; if (__predict_false(PMUTEX_TYPE(m->m_flags) == PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) { m->m_count--; @@ -991,7 +992,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, if (robust) _mutex_leave_robust(curthread, m); } - if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE) + if (!cv && private) THR_CRITICAL_LEAVE(curthread); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904121727.x3CHRJnh080839>