From 105ee6e5a9aae373e88d54ecbcd83ccb134cfc97 Mon Sep 17 00:00:00 2001 From: Antoine Faure Date: Wed, 9 Oct 2019 16:10:09 +0200 Subject: [PATCH] device: fix crash by handling connection cancellation --- src/devices/wwan/nm-modem-broadband.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 9910ffdb27..0510902a31 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -341,16 +341,23 @@ connect_ready (MMModemSimple *simple_iface, GAsyncResult *res, NMModemBroadband *self) { - ConnectContext *ctx = self->_priv.ctx; + ConnectContext *ctx = NULL; GError *error = NULL; NMModemIPMethod ip4_method = NM_MODEM_IP_METHOD_UNKNOWN; NMModemIPMethod ip6_method = NM_MODEM_IP_METHOD_UNKNOWN; - self->_priv.bearer = mm_modem_simple_connect_finish (simple_iface, res, &error); + MMBearer *bearer = mm_modem_simple_connect_finish (simple_iface, res, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + ctx = self->_priv.ctx; if (!ctx) return; + self->_priv.bearer = bearer; + if (!self->_priv.bearer) { if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN) || (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_UNAUTHORIZED) && @@ -619,7 +626,7 @@ connect_context_step (NMModemBroadband *self) mm_modem_simple_connect (self->_priv.simple_iface, ctx->connect_properties, - NULL, + ctx->cancellable, (GAsyncReadyCallback) connect_ready, self); break;