From 4dcb8edcc8f985ba25f83cccf0a7c8d2ceee74f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Fri, 1 Jul 2022 00:55:07 +0200 Subject: [PATCH] asymcute: Fix deadlocks in REGACK, SUBACK and UNSUBACK handler The handlers for these MQTT message lock the connection mutex on function entry. During automated testing of asymcute, I discovered return paths for these function which do not unlock the connection mutex. This results in a deadlock which prevents asymcute from sending any further messages. --- sys/net/application_layer/asymcute/asymcute.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/application_layer/asymcute/asymcute.c b/sys/net/application_layer/asymcute/asymcute.c index cf6a4cab32..7889436bc2 100644 --- a/sys/net/application_layer/asymcute/asymcute.c +++ b/sys/net/application_layer/asymcute/asymcute.c @@ -415,6 +415,7 @@ static void _on_regack(asymcute_con_t *con, const uint8_t *data, size_t len) /* finish the registration by applying the topic id */ asymcute_topic_t *topic = req->arg; if (topic == NULL) { + mutex_unlock(&con->lock); return; } @@ -497,6 +498,7 @@ static void _on_suback(asymcute_con_t *con, const uint8_t *data, size_t len) /* parse and apply assigned topic id */ asymcute_sub_t *sub = req->arg; if (sub == NULL) { + mutex_unlock(&con->lock); return; } @@ -534,6 +536,7 @@ static void _on_unsuback(asymcute_con_t *con, const uint8_t *data, size_t len) /* remove subscription from list */ asymcute_sub_t *sub = req->arg; if (sub == NULL) { + mutex_unlock(&con->lock); return; } else if (con->subscriptions == sub) { con->subscriptions = sub->next;