From cc3076be1db3ed528b8e5f2a9f4d3f608689f812 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Thu, 15 Feb 2024 07:03:00 +0100 Subject: [PATCH] modem: cmux: Prevent NULL deref in dlci_open_handler Prevent unlikely item == NULL scenario (CID 323102) and remove superflous cmux == NULL check (CID 334903) Signed-off-by: Bjarki Arge Andreasen --- subsys/modem/modem_cmux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/subsys/modem/modem_cmux.c b/subsys/modem/modem_cmux.c index 843cbf492ee..7f2728958e8 100644 --- a/subsys/modem/modem_cmux.c +++ b/subsys/modem/modem_cmux.c @@ -1015,13 +1015,16 @@ struct modem_pipe_api modem_cmux_dlci_pipe_api = { static void modem_cmux_dlci_open_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, open_work); + struct k_work_delayable *dwork; + struct modem_cmux_dlci *dlci; - if (dlci == NULL) { + if (item == NULL) { return; } + dwork = k_work_delayable_from_work(item); + dlci = CONTAINER_OF(dwork, struct modem_cmux_dlci, open_work); + dlci->state = MODEM_CMUX_DLCI_STATE_OPENING; struct modem_cmux_frame frame = {