]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
soc: qcom: fix endianness for QMI header
authorAlexander Wilhelm <alexander.wilhelm@westermo.com>
Thu, 22 May 2025 14:35:30 +0000 (16:35 +0200)
committerBjorn Andersson <andersson@kernel.org>
Tue, 17 Jun 2025 20:49:10 +0000 (15:49 -0500)
The members of QMI header have to be swapped on big endian platforms. Use
__le16 types instead of u16 ones.

Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
Fixes: 9b8a11e82615 ("soc: qcom: Introduce QMI encoder/decoder")
Fixes: 3830d0771ef6 ("soc: qcom: Introduce QMI helpers")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250522143530.3623809-3-alexander.wilhelm@westermo.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/qmi_encdec.c
drivers/soc/qcom/qmi_interface.c
include/linux/soc/qcom/qmi.h

index dafe0a4c202e1404ea13ad66d427ffe7dc8bbc93..7660a960fb45ea5dd03fdea3cefa08742f57d462 100644 (file)
@@ -776,9 +776,9 @@ void *qmi_encode_message(int type, unsigned int msg_id, size_t *len,
 
        hdr = msg;
        hdr->type = type;
-       hdr->txn_id = txn_id;
-       hdr->msg_id = msg_id;
-       hdr->msg_len = msglen;
+       hdr->txn_id = cpu_to_le16(txn_id);
+       hdr->msg_id = cpu_to_le16(msg_id);
+       hdr->msg_len = cpu_to_le16(msglen);
 
        *len = sizeof(*hdr) + msglen;
 
index bc6d6379d8b1bb2a43e99f2a14528f65e28b0e37..6500f863aae5ca218892d13233d4c9bf4b63a0f4 100644 (file)
@@ -400,7 +400,7 @@ static void qmi_invoke_handler(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
 
        for (handler = qmi->handlers; handler->fn; handler++) {
                if (handler->type == hdr->type &&
-                   handler->msg_id == hdr->msg_id)
+                   handler->msg_id == le16_to_cpu(hdr->msg_id))
                        break;
        }
 
@@ -488,7 +488,7 @@ static void qmi_handle_message(struct qmi_handle *qmi,
        /* If this is a response, find the matching transaction handle */
        if (hdr->type == QMI_RESPONSE) {
                mutex_lock(&qmi->txn_lock);
-               txn = idr_find(&qmi->txns, hdr->txn_id);
+               txn = idr_find(&qmi->txns, le16_to_cpu(hdr->txn_id));
 
                /* Ignore unexpected responses */
                if (!txn) {
@@ -514,7 +514,7 @@ static void qmi_handle_message(struct qmi_handle *qmi,
        } else {
                /* Create a txn based on the txn_id of the incoming message */
                memset(&tmp_txn, 0, sizeof(tmp_txn));
-               tmp_txn.id = hdr->txn_id;
+               tmp_txn.id = le16_to_cpu(hdr->txn_id);
 
                qmi_invoke_handler(qmi, sq, &tmp_txn, buf, len);
        }
index 469e02d2aa0d8157ab4732c0960dea73e52590fe..291cdc7ef49ce15dcd4c014850476486f0dab460 100644 (file)
@@ -24,9 +24,9 @@ struct socket;
  */
 struct qmi_header {
        u8 type;
-       u16 txn_id;
-       u16 msg_id;
-       u16 msg_len;
+       __le16 txn_id;
+       __le16 msg_id;
+       __le16 msg_len;
 } __packed;
 
 #define QMI_REQUEST    0