]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
soc: qcom: qmi_interface: Limit txn ids to U16_MAX
authorArun Kumar Neelakantam <aneela@codeaurora.org>
Wed, 3 Oct 2018 05:40:02 +0000 (11:10 +0530)
committerAndy Gross <andy.gross@linaro.org>
Wed, 14 Nov 2018 18:02:07 +0000 (10:02 -0800)
Txn IDs created up to INT_MAX cause overflow while storing
the IDs in u16 type supported by QMI header.

Limit the txn IDs max value to U16_MAX to avoid overflow.

Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
drivers/soc/qcom/qmi_interface.c
include/linux/soc/qcom/qmi.h

index 938ca41c56cdc794cd7bbc25409e8350668f0295..c239a28e503f93fd56935c6e9a865f4e64117df2 100644 (file)
@@ -318,7 +318,7 @@ int qmi_txn_init(struct qmi_handle *qmi, struct qmi_txn *txn,
        txn->dest = c_struct;
 
        mutex_lock(&qmi->txn_lock);
-       ret = idr_alloc_cyclic(&qmi->txns, txn, 0, INT_MAX, GFP_KERNEL);
+       ret = idr_alloc_cyclic(&qmi->txns, txn, 0, U16_MAX, GFP_KERNEL);
        if (ret < 0)
                pr_err("failed to allocate transaction id\n");
 
index f4de33654a6092b9c29ca50451534861e3937169..5efa2b67fa55792d37ecfe67b14ea9b0fca663fd 100644 (file)
@@ -166,7 +166,7 @@ struct qmi_ops {
 struct qmi_txn {
        struct qmi_handle *qmi;
 
-       int id;
+       u16 id;
 
        struct mutex lock;
        struct completion completion;