From patchwork Wed Oct 3 05:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Kumar Neelakantam X-Patchwork-Id: 10624315 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D97D415A7 for ; Wed, 3 Oct 2018 05:40:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBE50285FD for ; Wed, 3 Oct 2018 05:40:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0551285FF; Wed, 3 Oct 2018 05:40:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FBD285FD for ; Wed, 3 Oct 2018 05:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbeJCM1O (ORCPT ); Wed, 3 Oct 2018 08:27:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45168 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727261AbeJCM1O (ORCPT ); Wed, 3 Oct 2018 08:27:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5A4AF60C61; Wed, 3 Oct 2018 05:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538545224; bh=jsjxrL3tweSVlWRKUmeXfJxlcUzqbT5q82fzNyNYPe8=; h=From:To:Cc:Subject:Date:From; b=PTvGohUIr+G+oXQmJ8pj6nnuDQWrph5e9id/HyBGWZoeMluNb/o5VRpZeUwVR4eIM cEbUmIhjTnPgdUQ5kEW5/yVe0zcL4SX5vrUSMO+dGWadj7Yxdn6mq3hzYk8hP625uZ eofruHi/LQ1ss68DKjcFmtb/Wu02syQkw7s6mPnw= Received: from aneelaka-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: aneela@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D30DC60C61; Wed, 3 Oct 2018 05:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538545223; bh=jsjxrL3tweSVlWRKUmeXfJxlcUzqbT5q82fzNyNYPe8=; h=From:To:Cc:Subject:Date:From; b=LzlH4UXOIKY1ELzFQfb3Ta89Aj+AHi2VVzHs50BZDt+rEXKz+6R/P70tjSb5A4pzC fj9ZNsUQUIZPcjYVT5/panNAIPYqmKD8OMBoAHd3WhT/5Y+dPNHGSXk6/BMkI/CPHK aUyLmRGJpunvZsqwVLloQnX/Szn1u2UIXV/HgrR8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D30DC60C61 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=aneela@codeaurora.org From: Arun Kumar Neelakantam To: davem@davemloft.net, bjorn.andersson@linaro.org, clew@codeaurora.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, fw@strlen.de, hannes@stressinduktion.org, dvlasenk@redhat.com, nicolas.dechesne@linaro.org, Arun Kumar Neelakantam , Andy Gross , David Brown , linux-soc@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT) Subject: [PATCH] soc: qcom: qmi_interface: Limit txn ids to U16_MAX Date: Wed, 3 Oct 2018 11:10:02 +0530 Message-Id: <1538545205-17939-1-git-send-email-aneela@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Bjorn Andersson --- drivers/soc/qcom/qmi_interface.c | 2 +- include/linux/soc/qcom/qmi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index 938ca41c..c239a28 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -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"); diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h index f4de336..5efa2b6 100644 --- a/include/linux/soc/qcom/qmi.h +++ b/include/linux/soc/qcom/qmi.h @@ -166,7 +166,7 @@ struct qmi_ops { struct qmi_txn { struct qmi_handle *qmi; - int id; + u16 id; struct mutex lock; struct completion completion;