From ec8bbeeafcdce7c39ff0693ba5f474644d5b0ac7 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 4 Apr 2024 10:33:07 +0000 Subject: [PATCH] broadband-bearer: don't assume primary port always exists --- src/mm-broadband-bearer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index 573e3c9e..16269c14 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -147,7 +147,12 @@ common_get_at_data_port (MMBroadbandBearer *self, * actually a 'net' port, which the generic logic cannot handle, so if * that is the case, and we have no AT data ports specified, just fallback to the primary AT port. */ - data = (MMPort *) mm_base_modem_peek_port_primary (modem); + data = MM_PORT (mm_base_modem_peek_port_primary (modem)); + if (!data) { + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Couldn't connect: no AT data/primary port found: "); + return NULL; + } } g_assert (MM_IS_PORT_SERIAL_AT (data));