public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ufs: host: mediatek: Fix out-of-bounds access in MCQ IRQ mapping
@ 2025-08-04  6:01 peter.wang
  2025-08-06  2:10 ` Martin K. Petersen
  2025-08-13  2:26 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: peter.wang @ 2025-08-04  6:01 UTC (permalink / raw)
  To: linux-scsi, martin.petersen
  Cc: wsd_upstream, linux-mediatek, peter.wang, chun-hung.wu,
	alice.chao, cc.chou, chaotian.jing, jiajie.hao, yi-fan.peng,
	qilin.tan, lin.gui, tun-yu.yu, eddie.huang, naomi.chu, ed.tsai,
	bvanassche, dan.carpenter, stable

From: Peter Wang <peter.wang@mediatek.com>

This patch addresses a potential out-of-bounds access issue when
accessing 'host->mcq_intr_info[q_index]'. The value of 'q_index'
might exceed the valid array bounds if 'q_index == nr'.
The condition is corrected to 'q_index >= nr' to prevent
accessing invalid memory.

Fixes: 66e26a4b8a77 ("scsi: ufs: host: mediatek: Set IRQ affinity policy for MCQ mode")
Cc: <stable@vger.kernel.org>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
 drivers/ufs/host/ufs-mediatek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 86ae73b89d4d..f902ce08c95a 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -818,7 +818,7 @@ static u32 ufs_mtk_mcq_get_irq(struct ufs_hba *hba, unsigned int cpu)
 	unsigned int q_index;
 
 	q_index = map->mq_map[cpu];
-	if (q_index > nr) {
+	if (q_index >= nr) {
 		dev_err(hba->dev, "hwq index %d exceed %d\n",
 			q_index, nr);
 		return MTK_MCQ_INVALID_IRQ;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-13  2:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04  6:01 [PATCH v1] ufs: host: mediatek: Fix out-of-bounds access in MCQ IRQ mapping peter.wang
2025-08-06  2:10 ` Martin K. Petersen
2025-08-13  2:26 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox