public inbox for linux-phy@lists.infradead.org
 help / color / mirror / Atom feed
From: Xiangxu Yin via B4 Relay <devnull+xiangxu.yin.oss.qualcomm.com@kernel.org>
To: Vinod Koul <vkoul@kernel.org>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
	 linux-kernel@vger.kernel.org, fange.zhang@oss.qualcomm.com,
	 yongxing.mou@oss.qualcomm.com, li.liu@oss.qualcomm.com,
	 tingwei.zhang@oss.qualcomm.com,
	Konrad Dybcio <konradybcio@kernel.org>,
	 Dan Carpenter <dan.carpenter@linaro.org>,
	 Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Subject: [PATCH] phy: qcom: qmp-usbc: Fix out-of-bounds array access in dp swing config
Date: Fri, 27 Feb 2026 20:15:01 +0800	[thread overview]
Message-ID: <20260227-master-v1-1-8d91b9407fdb@oss.qualcomm.com> (raw)

From: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>

swing_tbl and pre_emphasis_tbl are 4x4 arrays (valid indices 0-3), but
the boundary check uses "> 4" instead of ">= 4", allowing index 4 to
cause an out-of-bounds access.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 81791c45c8e0 ("phy: qcom: qmp-usbc: Add QCS615 USB/DP PHY config and DP mode support")
Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
---
 drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
index 14feb77789b3..0dd7000614f4 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
@@ -794,7 +794,7 @@ static int qmp_v2_configure_dp_swing(struct qmp_usbc *qmp)
 		p_level = max(p_level, dp_opts->pre[i]);
 	}
 
-	if (v_level > 4 || p_level > 4) {
+	if (v_level >= 4 || p_level >= 4) {
 		dev_err(qmp->dev, "Invalid v(%d) | p(%d) level)\n",
 			v_level, p_level);
 		return -EINVAL;

---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260227-master-8b948c5633ea

Best regards,
-- 
Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>



-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

             reply	other threads:[~2026-02-27 12:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 12:15 Xiangxu Yin via B4 Relay [this message]
2026-02-27 16:50 ` [PATCH] phy: qcom: qmp-usbc: Fix out-of-bounds array access in dp swing config Konrad Dybcio
2026-02-27 19:50 ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260227-master-v1-1-8d91b9407fdb@oss.qualcomm.com \
    --to=devnull+xiangxu.yin.oss.qualcomm.com@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=fange.zhang@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=li.liu@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=tingwei.zhang@oss.qualcomm.com \
    --cc=vkoul@kernel.org \
    --cc=xiangxu.yin@oss.qualcomm.com \
    --cc=yongxing.mou@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox