svn commit: r346371 - stable/12/lib/libthr/thread
Konstantin Belousov
kib at FreeBSD.org
Fri Apr 19 12:30:16 UTC 2019
Author: kib
Date: Fri Apr 19 12:30:15 2019
New Revision: 346371
URL: https://svnweb.freebsd.org/changeset/base/346371
Log:
MFC r346158:
Do not access mutex memory after unlock.
PR: 237195
Modified:
stable/12/lib/libthr/thread/thr_mutex.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/lib/libthr/thread/thr_mutex.c
==============================================================================
--- stable/12/lib/libthr/thread/thr_mutex.c Fri Apr 19 10:52:54 2019 (r346370)
+++ stable/12/lib/libthr/thread/thr_mutex.c Fri Apr 19 12:30:15 2019 (r346371)
@@ -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);
}
More information about the svn-src-stable-12
mailing list