rem: mutex_unlock(&locking->mutex);
add: release_sem(locking->lock);
context: acquire_advisory_lock(struct vnode *vnode, struct flock *flock, bool wait){	FUNCTION(("acquire_advisory_lock(vnode = %p, flock = %p, wait = %s)\n",		vnode, flock, wait ? "yes" : "no"));	bool shared = flock->l_type == F_RDLCK;	status_t status = B_OK;restart:	// if this vnode has an advisory_locking structure attached,	// lock that one and search for any colliding lock	struct advisory_locking *locking = get_advisory_locking(vnode);	sem_id waitForLock = -1;	if (locking != NULL) {		// test for collisions		struct advisory_lock *lock = NULL;		while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, lock)) != NULL) {			if (lock->offset <= flock->l_start + flock->l_len				&& lock->offset + lock->length > flock->l_start) {				// locks do overlap				if (!shared || !lock->shared) {					// we need to wait					waitForLock = locking->wait_sem;					break;				}			}		}		put_advisory_locking(locking);	}	// wait for the lock if we have to, or else return immediately	if (waitForLock >= B_OK) {		if (!wait)			status = B_PERMISSION_DENIED;		else {			// ToDo: this is the standard condvar problem; there is a big race			//	condition here: between here and the put_advisory_locking() call			//	above, a release could already have happened!			status = acquire_sem_etc(waitForLock, 1, B_CAN_INTERRUPT, 0);			if (status == B_OK) {				// see if we're still colliding				goto restart;			}		}	}	if (status < B_OK)		return status;	// install new lock	mutex_lock(&sVnodeMutex);	locking = vnode->advisory_locking;	if (locking == NULL) {		status = create_advisory_locking(vnode);		locking = vnode->advisory_locking;	}	if (locking != NULL)		mutex_lock(&locking->mutex);	mutex_unlock(&sVnodeMutex);	if (status < B_OK)		return status;	struct advisory_lock *lock = (struct advisory_lock *)malloc(sizeof(struct advisory_lock));	if (lock == NULL) {		if (waitForLock >= B_OK)			release_sem_etc(waitForLock, 1, B_RELEASE_ALL);		mutex_unlock(&locking->mutex);		return B_NO_MEMORY;	}	lock->team = team_get_current_team_id();	// values must already be normalized when getting here	lock->offset = flock->l_start;	lock->length = flock->l_len;	lock->shared = shared;	list_add_item(&locking->locks, lock);	mutex_unlock(&locking->mutex);	return status;}