Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: qcom: qmi_interface: Limit txn ids to U16_MAX

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>

authored by

Arun Kumar Neelakantam and committed by
Andy Gross
c4fe17e0 e0f2cfeb

+2 -2
+1 -1
drivers/soc/qcom/qmi_interface.c
··· 318 318 txn->dest = c_struct; 319 319 320 320 mutex_lock(&qmi->txn_lock); 321 - ret = idr_alloc_cyclic(&qmi->txns, txn, 0, INT_MAX, GFP_KERNEL); 321 + ret = idr_alloc_cyclic(&qmi->txns, txn, 0, U16_MAX, GFP_KERNEL); 322 322 if (ret < 0) 323 323 pr_err("failed to allocate transaction id\n"); 324 324
+1 -1
include/linux/soc/qcom/qmi.h
··· 166 166 struct qmi_txn { 167 167 struct qmi_handle *qmi; 168 168 169 - int id; 169 + u16 id; 170 170 171 171 struct mutex lock; 172 172 struct completion completion;