From ae09baf61b208bb155ace947b128abefb00b8e4d Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 22 Jul 2021 16:06:01 +0200 Subject: port-qmi: cleanly close device if an open operation failed ModemManager[703345]: [1626962477.971869] [modem0] couldn't open QMI port with data format update: Unexpected kernel data mode: cannot setup using CTL ModemManager[703345]: [1626962477.972197] [cdc-wdm0/qmi] Opening QMI device... ModemManager[703345]: [1626962477.972310] [cdc-wdm0/qmi] Checking if QMI device already opening... ModemManager[703345]: [1626962477.975182] [modem0] couldn't start initialization: QMI device open/close operation in progress --- src/mm-port-qmi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c index ba81452d..9263ae86 100644 --- a/src/mm-port-qmi.c +++ b/src/mm-port-qmi.c @@ -2442,9 +2442,12 @@ port_open_step (GTask *task) else if (ctx->kernel_data_modes & MM_PORT_QMI_KERNEL_DATA_MODE_802_3) open_flags |= QMI_DEVICE_OPEN_FLAGS_NET_802_3; else { - g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Unexpected kernel data mode: cannot setup using CTL"); - g_object_unref (task); + /* Set error and jump to last step, so that we cleanly close the device + * in case we need to reopen it right away */ + ctx->error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Unexpected kernel data mode: cannot setup using CTL"); + ctx->step = PORT_OPEN_STEP_LAST; + port_open_step (task); return; } -- cgit v1.2.3-70-g09d2