diff --git a/subsys/modem/modem_cmux.c b/subsys/modem/modem_cmux.c index 7f2728958e8..a14d20d4456 100644 --- a/subsys/modem/modem_cmux.c +++ b/subsys/modem/modem_cmux.c @@ -1042,14 +1042,18 @@ static void modem_cmux_dlci_open_handler(struct k_work *item) static void modem_cmux_dlci_close_handler(struct k_work *item) { - struct k_work_delayable *dwork = k_work_delayable_from_work(item); - struct modem_cmux_dlci *dlci = CONTAINER_OF(dwork, struct modem_cmux_dlci, close_work); - struct modem_cmux *cmux = dlci->cmux; + struct k_work_delayable *dwork; + struct modem_cmux_dlci *dlci; + struct modem_cmux *cmux; - if (cmux == NULL) { + if (item == NULL) { return; } + dwork = k_work_delayable_from_work(item); + dlci = CONTAINER_OF(dwork, struct modem_cmux_dlci, close_work); + cmux = dlci->cmux; + dlci->state = MODEM_CMUX_DLCI_STATE_CLOSING; struct modem_cmux_frame frame = {