kernel/port: Handle mutex_lock returning an error status code.

This can occur if the mutex in question is destroyed while
we are waiting for it.
This commit is contained in:
Augustin Cavalier 2019-11-23 15:08:27 -05:00
parent 3c47c28a67
commit 057719ef90

View File

@ -633,9 +633,10 @@ get_locked_port(port_id id) GCC_2_NRV(portRef)
portRef.SetTo(sPorts.Lookup(id));
}
if (portRef != NULL && portRef->state == Port::kActive)
mutex_lock(&portRef->lock);
else
if (portRef != NULL && portRef->state == Port::kActive) {
if (mutex_lock(&portRef->lock) != B_OK)
portRef.Unset();
} else
portRef.Unset();
return portRef;