Do not access mutex memory after unlock.
PR: 237195 Reported by: freebsd@hurrikhan.eu Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
333f08f7aa
commit
5068f1f168
@ -949,7 +949,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer)
|
||||
{
|
||||
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, int *mtx_defer)
|
||||
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, int *mtx_defer)
|
||||
if (robust)
|
||||
_mutex_leave_robust(curthread, m);
|
||||
}
|
||||
if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE)
|
||||
if (!cv && private)
|
||||
THR_CRITICAL_LEAVE(curthread);
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user