port-qmi: cleanly close device if an open operation failed

ModemManager[703345]: <debug> [1626962477.971869] [modem0] couldn't open QMI port with data format update: Unexpected kernel data mode: cannot setup using CTL
   ModemManager[703345]: <debug> [1626962477.972197] [cdc-wdm0/qmi] Opening QMI device...
   ModemManager[703345]: <debug> [1626962477.972310] [cdc-wdm0/qmi] Checking if QMI device already opening...
   ModemManager[703345]: <warn>  [1626962477.975182] [modem0] couldn't start initialization: QMI device open/close operation in progress
This commit is contained in:
Aleksander Morgado
2021-07-22 16:06:01 +02:00
parent 9be34affe2
commit ae09baf61b

View File

@@ -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;
}