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
28ce2bc1b5
commit
b8f75b175c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=346158
@ -949,7 +949,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer)
|
|||||||
{
|
{
|
||||||
struct pthread *curthread;
|
struct pthread *curthread;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
int deferred, error, robust;
|
int deferred, error, private, robust;
|
||||||
|
|
||||||
if (__predict_false(m <= THR_MUTEX_DESTROYED)) {
|
if (__predict_false(m <= THR_MUTEX_DESTROYED)) {
|
||||||
if (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);
|
return (EPERM);
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
private = (m->m_flags & PMUTEX_FLAG_PRIVATE) != 0;
|
||||||
if (__predict_false(PMUTEX_TYPE(m->m_flags) ==
|
if (__predict_false(PMUTEX_TYPE(m->m_flags) ==
|
||||||
PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) {
|
PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) {
|
||||||
m->m_count--;
|
m->m_count--;
|
||||||
@ -991,7 +992,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer)
|
|||||||
if (robust)
|
if (robust)
|
||||||
_mutex_leave_robust(curthread, m);
|
_mutex_leave_robust(curthread, m);
|
||||||
}
|
}
|
||||||
if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE)
|
if (!cv && private)
|
||||||
THR_CRITICAL_LEAVE(curthread);
|
THR_CRITICAL_LEAVE(curthread);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user