From 19f6d15edfcf3f63a334cda6edc23cf3f44a9719 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 17 Apr 2025 20:31:53 -0500 Subject: [PATCH] broadband-modem-qmi,broadband-modem-mbim: always use SMS_PART_INVALID_INDEX unstored parts MMSmsList has logic to allow multiple unstored messages as long as they use SMS_PART_INVALID_INDEX. These messages aren't stored so they don't have an index. But the MBIM and QMI modems used index 0 for unstored messages, meaning there could only ever be one and also that multipart messages would fail to be combined. Let's fix that by just using SMS_PART_INVALID_INDEX for every scenario where an unstored message comes in. Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/979 Signed-off-by: Dan Williams (cherry picked from commit 1d5cc0addb6576d007183454c0702d8ee3ab586f) --- src/mm-broadband-modem-mbim.c | 31 ++++++++++++++++++++++++++----- src/mm-broadband-modem-qmi.c | 10 +++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 8116d201..4b6529ac 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -5840,6 +5840,7 @@ static gboolean process_pdu_messages (MMBroadbandModemMbim *self, guint32 messages_count, MbimSmsPduReadRecordArray *pdu_messages, guint expected_index, + gboolean unstored, GError **error); static void @@ -5864,6 +5865,7 @@ sms_notification_read_flash_sms (MMBroadbandModemMbim *self, messages_count, pdu_messages, SMS_PART_INVALID_INDEX, + TRUE, &error)) mm_obj_dbg (self, "flash SMS message reading failed: %s", error->message); } @@ -5943,6 +5945,7 @@ alert_sms_read_query_ready (MbimDevice *device, messages_count, pdu_messages, ctx->expected_index, + FALSE, &error)) mm_obj_dbg (ctx->self, "SMS message reading failed: %s", error->message); @@ -9024,12 +9027,13 @@ load_initial_sms_parts_finish (MMIfaceModemMessaging *self, static void add_sms_part (MMBroadbandModemMbim *self, const MbimSmsPduReadRecord *pdu, + guint part_index, guint expected_index) { MMSmsPart *part; g_autoptr(GError) error = NULL; - part = mm_sms_part_3gpp_new_from_binary_pdu (pdu->message_index, + part = mm_sms_part_3gpp_new_from_binary_pdu (part_index, pdu->pdu_data, pdu->pdu_data_size, self, @@ -9062,6 +9066,7 @@ process_pdu_messages (MMBroadbandModemMbim *self, guint32 messages_count, MbimSmsPduReadRecordArray *pdu_messages, guint expected_index, + gboolean unstored, GError **error) { guint i; @@ -9087,11 +9092,26 @@ process_pdu_messages (MMBroadbandModemMbim *self, mm_obj_dbg (self, "%u SMS PDUs reported", messages_count); for (i = 0; i < messages_count; i++) { - if (pdu_messages[i]) { - mm_obj_dbg (self, "processing SMS PDU %u/%u...", i+1, messages_count); - add_sms_part (self, pdu_messages[i], expected_index); - } else + guint message_index; + + if (!pdu_messages[i]) { mm_obj_dbg (self, "ignoring invalid SMS PDU %u/%u...", i+1, messages_count); + continue; + } + + mm_obj_dbg (self, "processing SMS PDU %u/%u...", i+1, messages_count); + + message_index = pdu_messages[i]->message_index; + if (unstored && message_index != 0) { + mm_obj_warn (self, + "processed unstored PDU with non-zero message index (%u)", + message_index); + } + + add_sms_part (self, + pdu_messages[i], + unstored ? SMS_PART_INVALID_INDEX : message_index, + expected_index); } return TRUE; @@ -9126,6 +9146,7 @@ sms_read_query_ready (MbimDevice *device, messages_count, pdu_messages, SMS_PART_INVALID_INDEX, + FALSE, &error)) g_task_return_error (task, error); else diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index bdef0737..7ce39d59 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -8380,7 +8380,6 @@ messaging_event_report_indication_cb (QmiClientNas *client, QmiWmsAckIndicator ack_ind; guint32 transaction_id; QmiWmsMessageFormat msg_format; - QmiWmsMessageTagType tag; GArray *raw_data = NULL; /* Handle transfer-route MT messages */ @@ -8425,13 +8424,10 @@ messaging_event_report_indication_cb (QmiClientNas *client, } /* Defaults for transfer-route messages, which are not stored anywhere */ - storage = QMI_WMS_STORAGE_TYPE_NONE; - memory_index = 0; - tag = QMI_WMS_MESSAGE_TAG_TYPE_MT_NOT_READ; add_new_read_sms_part (MM_IFACE_MODEM_MESSAGING (self), - storage, - memory_index, - tag, + QMI_WMS_STORAGE_TYPE_NONE, + SMS_PART_INVALID_INDEX, + QMI_WMS_MESSAGE_TAG_TYPE_MT_NOT_READ, msg_format, TRUE, raw_data);