From 07893109ea9173e191e75380d18162ef45f560b9 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 10 Sep 2026 15:34:41 +0000 Subject: [PATCH] bearer-mbim: avoid deadlock when cancelling async SLAAC logic g_cancellable_disconnect() must not be called from within the cancellable callback, or it will deadlock. Signed-off-by: Aleksander Morgado --- src/mm-bearer-mbim.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 63aebb5a..06e5b77a 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -641,9 +641,10 @@ ip_configuration_async_cleanup (GTask *task) ctx = g_task_get_task_data (task); - g_assert (ctx->async_slaac_cancellation_id); - g_cancellable_disconnect (g_task_get_cancellable (task), ctx->async_slaac_cancellation_id); - ctx->async_slaac_cancellation_id = 0; + if (ctx->async_slaac_cancellation_id) { + g_cancellable_disconnect (g_task_get_cancellable (task), ctx->async_slaac_cancellation_id); + ctx->async_slaac_cancellation_id = 0; + } g_assert (ctx->async_slaac_notification_id); if (g_signal_handler_is_connected (ctx->mbim, ctx->async_slaac_notification_id)) @@ -670,6 +671,12 @@ static void ip_configuration_async_cancelled (GCancellable *cancellable, GTask *task) { + ConnectContext *ctx; + + /* Avoid the explicit g_cancellable_disconnect(), which would deadlock */ + ctx = g_task_get_task_data (task); + ctx->async_slaac_cancellation_id = 0; + ip_configuration_async_cleanup (task); g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_CANCELLED, "Cancelled waiting for SLAAC notification");