fixed potetial deadlock
diff --git a/src/mod_netconf.c b/src/mod_netconf.c
index 44350d4..9ae6f61 100644
--- a/src/mod_netconf.c
+++ b/src/mod_netconf.c
@@ -1728,8 +1728,6 @@
 	if (rpc == NULL) {
 		DEBUG("mod_netconf: creating rpc request failed");
 		reply = create_error("Creation of RPC request failed.");
-		DEBUG("UNLOCK mutex %s", __func__);
-		pthread_mutex_unlock(&locked_session->lock);
 		return reply;
 	}
 
diff --git a/src/notification-server.c b/src/notification-server.c
index 9feb455..2c86575 100644
--- a/src/notification-server.c
+++ b/src/notification-server.c
@@ -443,45 +443,35 @@
 	target_session = get_ncsession_from_key(session_hash);
 	if (target_session == NULL) {
 		DEBUG("no session found last_session_key (%s)", session_hash);
-		if (pthread_rwlock_unlock (&session_lock) != 0) {
-			DEBUG("Error while unlocking rwlock");
-			return;
-		}
-		return;
+		goto unlock_glob;
 	}
 	if (pthread_mutex_lock(&target_session->lock) != 0) {
 		DEBUG("Error while locking rwlock");
 	}
-	if (pthread_rwlock_unlock(&session_lock) != 0) {
-		DEBUG("Error while locking rwlock");
-	}
 
 	if (target_session->notifications == NULL) {
 		DEBUG("target_session->notifications is NULL");
-		if (pthread_mutex_unlock(&target_session->lock) != 0) {
-			DEBUG("Error while unlocking rwlock: %d (%s)", errno, strerror(errno));
-			return;
-		}
-		return;
+		goto unlock_all;
 	}
 	DEBUG("notification: ready to push to notifications queue");
 	ntf = (notification_t *) apr_array_push(target_session->notifications);
 	if (ntf == NULL) {
 		DEBUG("Failed to allocate element ");
-		if (pthread_mutex_unlock(&target_session->lock) != 0) {
-			DEBUG("Error while unlocking rwlock");
-			return;
-		}
-		return;
+		goto unlock_all;
 	}
 	ntf->eventtime = eventtime;
 	ntf->content = strdup(content);
 
 	DEBUG("added notif to queue %u (%s)", (unsigned int) ntf->eventtime, "notification");
 
+unlock_all:
 	if (pthread_mutex_unlock(&target_session->lock) != 0) {
 		DEBUG("Error while unlocking rwlock");
 	}
+unlock_glob:
+	if (pthread_rwlock_unlock(&session_lock) != 0) {
+		DEBUG("Error while locking rwlock");
+	}
 }
 
 /**