Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Apr 2019 12:30:15 +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-12@freebsd.org
Subject:   svn commit: r346371 - stable/12/lib/libthr/thread
Message-ID:  <201904191230.x3JCUFCN067571@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904191230.x3JCUFCN067571>