From 9633fb70a0117d29c9b58bad3dc517ea69bcba5d Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Thu, 15 Feb 2024 06:47:11 +0100 Subject: [PATCH] modem: cmux: Prevent NULL deref in connect_handler Prevent unlikely item == NULL scenario (CID 323091) and remove superflous cmux == NULL check (CID 334904) 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 a6235e891c1..843cbf492ee 100644 --- a/subsys/modem/modem_cmux.c +++ b/subsys/modem/modem_cmux.c @@ -899,13 +899,16 @@ static void modem_cmux_transmit_handler(struct k_work *item) static void modem_cmux_connect_handler(struct k_work *item) { - struct k_work_delayable *dwork = k_work_delayable_from_work(item); - struct modem_cmux *cmux = CONTAINER_OF(dwork, struct modem_cmux, connect_work); + struct k_work_delayable *dwork; + struct modem_cmux *cmux; - if (cmux == NULL) { + if (item == NULL) { return; } + dwork = k_work_delayable_from_work(item); + cmux = CONTAINER_OF(dwork, struct modem_cmux, connect_work); + cmux->state = MODEM_CMUX_STATE_CONNECTING; struct modem_cmux_frame frame = {