From 9448a266eedd72175b5e55e42e3d25cba2e0868b 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) (cherry picked from commit cc3076be1db3ed528b8e5f2a9f4d3f608689f812) Original-Signed-off-by: Bjarki Arge Andreasen GitOrigin-RevId: cc3076be1db3ed528b8e5f2a9f4d3f608689f812 Change-Id: I910d3e00bac478894de13a48380d0f3ffb50dfbc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5299387 Tested-by: Fabio Baltieri Reviewed-by: Fabio Baltieri Tested-by: ChromeOS Prod (Robot) Commit-Queue: Fabio Baltieri --- 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 = {